A collection of standards as PHP Enums: ISO3166, ISO4217, ISO639...
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.
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;
composer require prinsfrank/standards
Or for development only;
composer require prinsfrank/standards --dev
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 is identical, so it is possible to convert between these.
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.
All the Alpha3, Numeric and Name values have a corresponding enum in the other currency enums. These can be converted using their corresponding methods.
The language specification is a bit more complex, as there are 20 alpha3 codes that have both a Bibliographic and a Terminology code. All the other ones have a common one. So if you decide you want the alpha3 representation of an alpha2 code, you can convert it to either Terminology or Bibliographic, where if it is not available you will get an instance of the common enum. More documentation can be found here.
Country calling codes are quite straight forward. One Exception is that the +1 prefix is used across a lot of countries, and there is no standard for sub numbering plans.
HTTP Status codes are quite straight forward. For some code examples you can look in the documentation.