Download the PHP package prinsfrank/standards without Composer
On this page you can find all versions of the php package prinsfrank/standards. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download prinsfrank/standards
More information about prinsfrank/standards
Files in prinsfrank/standards
Package standards
Short Description A collection of standards as PHP Enums: ISO3166, ISO4217, ISO639...
License MIT
Informations about the package standards
Standards
A collection of standards as PHP Enums
Daily updated from their sources, whether it is ISO or IANA directly, or a maintaining party like the SIX Group or the US Library of Congress.
Setup
Note Make sure you are running PHP 8.1 or higher to use this package
To start right away, run the following command in your composer project;
Or for development only;
Daily updated from their source
How this package works
This package implements a bunch of specs as PHP Enums, so you can typehint them in methods. Currently, all specs are implemented as backed enums. That means that besides a name, they have also an internal 'value', either as an integer or a string.
In the Country, Currency and language specifications, there is also a relation between different enums. For example, the Alpha2 country code 'NL' is related to the Alpha3 'NLD', the numeric value '528' and the name 'Netherlands (the)'. Internally, these specs rely on the fact that the keys for these values are identical, so it is possible to convert between these.
Entities and their relations
All specifications in this package are closely related, except for the Http status code and methods. Not all relations are bidirectional though. For example, a language tag is build up of a language and optionally a country, but only a country cannot be converted to a language tag.
Below you can find an overview of all the relationships between specifications.
Upgrading
This package adheres to semver. This means that there are no breaking changes between minor releases (for example from 1.1 to 1.2), but that breaking changes are released as a major release (for example from 1.x to 2.x). To read about upgrading from one major release to the next, please refer to the UPGRADING.md file in the root of this project.
Some powerful use cases
Format a complete phone number string based on the users country;
Automatically select a supported language from an HTTP request;
Listing all country calling codes sorted by country name in a dropdown;
Country (ISO3166-1)
:mortar_board: Alpha2/3 country codes are always UPPERCASE to avoid confusion with language codes. It is recommended to use Alpha2/Alpha3 codes when exposing the specification in APIs
At a glance
All the Alpha2, Alpha3, Numeric and Name values have a corresponding enum in the other country enums. These can be converted using their corresponding methods (toAlpha2, toAlpha3 etc...).
Country group membership can be checked by calling the isMemberOf
method, supplying the FQN of a class that implements the GroupInterface
. Several country groups are available: BRICS, EEA, EFTA etc. Countries can also have subdivisions, which can be of several types: countries, provinces, etc.
Full documentation
### CountryAlpha2 ### CountryAlpha3 ### CountryNumeric ### CountrySubdivision ###Country Calling Codes (ITU-T E.164)
:mortar_board: Country calling codes can be anywhere from 1 to 3 digits, and can span several countries. There are no leading zeros in this specification.
At a glance
Country calling codes are quite straight forward. One country can have multiple country calling codes though, And one country calling code can span multiple countries. That's why the forCountry
and getCountriesAlpha2
both return an array of country calling codes/countries and not a single item.
Currency (ISO4217)
:mortar_board: Alpha3 codes are uppercase. When communicating or storing currencies, it is recommended to do so using the Alpha3 or Numeric representation.
At a glance
All the Alpha3, Numeric and Name values have a corresponding enum in the other currency enums. These can be converted using their corresponding methods (toCurrencyAlpha3, etc...). A fourth enum is available that maps all currencies to a currency symbol, that can be accessed by calling the 'getSymbol' method.
Full documentation
### CurrencyAlpha3 ### CurrencyNumeric ### CurrencySymbol ### CurrencyNameHTTP Methods
At a glance
HTTP Status Codes
At a glance
There can be status codes that are temporarily assigned. Those are marked with the TemporaryAssignment
attribute. To check if a specific case is temporarily assigned, you can use the isTemporaryAssignment
method which returns a boolean, or getTemporaryAssignmentExpiresAt
which returns a DateTimeImmutable or null.
International Call Prefixes (ITU-T E.164)
Different countries have different international call prefixes. This is a spec extracted from ITU-T E.164 listing all possible international call prefixes.
At a glance
Language (ISO639)
:mortar_board: Language codes are always in lowercase to avoid confusion with country codes.
:mortar_board: The alpha2 specification has 184 languages, the alpha3 Bibliographic/Terminology specification has 486 languages and the alpha3 Extensive specification has 7908 languages.
:mortar_board: If you have to choose between the alpha3 Bibliographic and Terminology specification, the Terminology specification is more widely used.
At a glance
There are four language code specifications:
- 184 Language Alpha2 (ISO 639-1)
- 486 Language Alpha3 Bibliographic (ISO 639-2)
- 486 Language Alpha3 Terminology (ISO 639-2)
- 7908 Language Alpha3 Extensive (ISO 639-3)
As you see, the Bibliographic and Terminology specifications have an identical number of languages, so there is a one-to-one relation between these.
Full documentation
### LanguageAlpha2 (ISO 639-1) ### LanguageAlpha3Bibliographic (ISO 639-2) ### LanguageAlpha3Terminology (ISO 639-2) ### LanguageAlpha3Extensive (ISO 639-3)Language Tags (RFC 5646)
:mortar-board: Language tags always have a primary tag, and can have an extension, script, region, one or more variants, one or more extension and/or a private subtag.
At a glance
Geographic regions (M49)
:mortar_board: Geographic regions are represented by three digits. Leading zeros are required. Each geographic region can span multiple other geographic regions or countries.
At a glance
National Call Prefixes (ITU-T E.164)
Different countries have different national call prefixes;
At a glance
Scripts
At a glance
Full documentation
### ScriptAlias PHP has regex support for detecting scripts using the following notation: Match any Arabic character Match any NON-Arabic character Not all scripts are supported by PHP regular expressions. An exhaustive list can be found in the [PHP documentation for Unicode character properties](https://www.php.net/manual/en/regexp.reference.unicode.php). For convenience, the information on that page is parsed daily and supplied in this package using the `isSupportedByPHPRegex` method and `SupportedByPHPRegex` attribute which is the underlying information used by the `isSupportedByPHPRegex` method. ### ScriptCode ### ScriptName ### ScriptNumberTLDs
There are currently 6 types of Top Level Domains:
- CountryCode
- GenericRestricted
- Generic
- Infrastructure
- Sponsored
- Test
Most of these specification have several TLDs that are 'unmanaged' and are thus not currently available. Those are marked as deprecated, but are kept in the specification. There is one exception: All Test TLDs are always unmanaged and are thus never marked as deprecated.
CountryCodeTLD
Where a TLD is marked as unmanaged by IANA it is marked as deprecated.
GenericRestrictedTLD
Where a TLD is marked as unmanaged by IANA it is marked as deprecated.
GenericTLD
Where a TLD is marked as unmanaged by IANA it is marked as deprecated.
InfrastructureTLD
Where a TLD is marked as unmanaged by IANA it is marked as deprecated.
SponsoredTLD
Where a TLD is marked as unmanaged by IANA it is marked as deprecated.
TestTLD
All Test TLDs are always unmanaged and are thus never marked as deprecated.
All versions of standards with dependencies
ext-intl Version *
ext-mbstring Version *
prinsfrank/enums Version ^1.4