Download the PHP package amondar-libs/php-state-flow without Composer

On this page you can find all versions of the php package amondar-libs/php-state-flow. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-state-flow

amondar-libs/php-state-flow

A lightweight PHP package for working with U.S. state codes and names.

It provides:

Requirements

Installation

Quick Start

Core Concepts

There can be only one

This package developed with only one thing in mind:

That's why keys are lower cased and values are normalized.

Default Vocabulary

By default, all methods use Amondar\PhpStateFlow\State, which contains 48 U.S. states.

Custom Vocabulary

Most methods accept a third argument ($vocabulary) with a class-string of a backed enum. This allows reuse of the same helpers with your own enum dataset.

API Reference

getAbbreviations(string $vocabulary = State::class): array

Returns all enum case names (state abbreviations by default), e.g. ['AL', 'AZ', ..., 'WY'].

getCount(string $vocabulary = State::class): int

Returns total number of items in the vocabulary.

getNames(string $vocabulary = State::class): array

Returns all enum backed values (state names by default), e.g. ['Alabama', 'New York', ...].

getAbbreviationsRegex(string $vocabulary = State::class): string

Returns a pipe-separated regex fragment of codes, e.g. AL|AZ|AR|....

getNamesRegex(string $vocabulary = State::class): string

Returns a pipe-separated regex fragment of names, e.g. Alabama|Arizona|....

getAbbreviationByNameMap(string $vocabulary = State::class): array

Returns a map of normalized snake-case labels to enum values.

Examples:

getNameByAbbreviationMap(string $vocabulary = State::class): array

Returns a map of lowercase enum values to human-readable labels.

Examples:

getAbbreviation(string $name, bool $lower = false, string $vocabulary = State::class): ?string

Converts a full state name to its short code.

Behavior:

getName(string $short, bool $lower = false, string $vocabulary = State::class): ?string

Converts a short code to full state name.

Behavior:

getCityRegex(int $maxCityName = 30, ?string $defaultCity = null, string $vocabulary = State::class): string

Builds a regex fragment for values like:

Supports:

getOriginRegex(int $maxCityName = 30, string $vocabulary = State::class): string

Builds a regex fragment that matches:

search(string $query, string $vocabulary = State::class): array

Searches states by abbreviation fragment and returns matched pairs as:

Behavior:

getRandom(string $vocabulary = State::class): array{abbreviation: string, name: string}

Returns one random item from vocabulary as an associative pair:

normalizeNameKey(string $name): string

Normalizes a given name key by converting it to lowercase, replacing spaces and hyphens with underscores, and trimming excess spaces.

Behavior:

Using a Custom Enum Vocabulary

Caching Notes

This package caches computed arrays/regex strings in static in-memory properties for the current PHP process.

Testing

Run tests with Pest:

Or run parallel tests via composer script:

License

MIT. See LICENSE.md.


All versions of php-state-flow with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package amondar-libs/php-state-flow contains the following files

Loading the files please wait ...