standards

A collection of standards as PHP Enums: ISO3166, ISO4217, ISO639...

MIT License

Downloads
223.2K
Stars
378
Committers
7

Bot releases are hidden (Show)

standards - v2.5.0 Extensive language tags from ISO639-3 and several fixes

Published by PrinsFrank 12 months ago

What's Changed

Full Changelog: https://github.com/PrinsFrank/standards/compare/v2.4.0...v2.5.0

standards - v2.4.0 Geographic regions from M49 added

Published by PrinsFrank almost 1 year ago

What's Changed

Full Changelog: https://github.com/PrinsFrank/standards/compare/v2.3.0...v2.4.0

standards - v2.3.0 Scripts added: Latin, Hangul etc (ISO-15924)

Published by PrinsFrank about 1 year ago

What's Changed

Full Changelog: https://github.com/PrinsFrank/standards/compare/v2.2.0...v2.3.0

standards - v2.2.0 Country groups added: EU, EEA, EFTA, BRICS etc

Published by PrinsFrank about 1 year ago

What's Changed

Full Changelog: https://github.com/PrinsFrank/standards/compare/v2.1.0...v2.2.0

standards - v2.1.0 Currency symbols added

Published by PrinsFrank over 1 year ago

standards - v2.0.1 "Netherlands (the)" has been renamed to "Netherlands (Kingdom of the)"

Published by PrinsFrank over 1 year ago

What's Changed

"Netherlands (the)" has been renamed to "Netherlands (Kingdom of the)" in the CountryName specification by @github-actions in https://github.com/PrinsFrank/standards/pull/51

Full Changelog: https://github.com/PrinsFrank/standards/compare/v2.0.0...v2.0.1

standards - v2.0.0 Readability Improvements

Published by PrinsFrank over 1 year ago

As this package is getting adopted and more people start using it, I got some valid feedback on the readability of the standards in codebases.

  • If you want to use a country code in code, you need to navigate the namespaces or know the ISO code of the spec for the country codes
  • If a country has a long formal name, using the enum name may span an entire line of code decreasing readability.

This update solves both of these problems.

For an upgrade guide please check the UPGRADING.md in the root of this project.

Full Changelog: https://github.com/PrinsFrank/standards/compare/v1.6.0...v2.0.0

standards - v1.6.0 Added short country code variant

Published by PrinsFrank over 1 year ago

As the country code enums names are based on the actual country name, they can become quite long and decrease readability when used in code. As to not make any backwards incompatible changes, a new set of country code enums was added in the CountryCodeShort namespace that are optimised for use in code.

standards - v1.5.1 Croation Kuna has been replaced by the Euro, so it has been deprecated

Published by PrinsFrank almost 2 years ago

What's Changed

As of today Croatia joined the Eurozone and Schengen area, and the country will use the Euro instead of the Croatian Kuna. As such, the Kuna has already been removed from the ISO4217 specification by the maintaining upstream party for it - the six group.

To maintain backwards compatibility in this minor release, the enum cases will stay in this specification package and will just be marked as deprecated.

Full Changelog: https://github.com/PrinsFrank/standards/compare/v1.5.0...v1.5.1

standards - v1.5.0 Added HTTP Methods

Published by PrinsFrank almost 2 years ago

What's Changed

  • Added HTTP Methods

Other changes

Full Changelog: https://github.com/PrinsFrank/standards/compare/v1.4.0...v1.5.0

standards - v1.4.0 Add UnitEnum utility class

Published by PrinsFrank about 2 years ago

What's Changed

  • Add UnitEnum utility class providing similar function as BackedEnum functionality but for UnitEnums instead.
  • Update the six group datasource url for currency codes as it has been update on their website by @PrinsFrank in https://github.com/PrinsFrank/standards/pull/44

Full Changelog: https://github.com/PrinsFrank/standards/compare/v1.3.0...v1.4.0

standards - v1.3.0 Expand BackedEnum utility class with ::names, ::values and ::toArray

Published by PrinsFrank about 2 years ago

What's Changed

Full Changelog: https://github.com/PrinsFrank/standards/compare/v1.2.0...v1.3.0

standards - v1.2.0 Added Country calling codes

Published by PrinsFrank about 2 years ago

What's Changed

Full Changelog: https://github.com/PrinsFrank/standards/compare/v1.1.0...v1.2.0

standards - v1.1.0 Turkiye rename & lots of new features

Published by PrinsFrank over 2 years ago

What's Changed

Turkey, Türkiye and BC key changes.

A new minor version is released as Turkey has now officially been renamed to Türkiye in ISO3166.

This brought one major challenge though; Renaming enum names are breaking changes, and releasing a new major version for every country rename is not ideal and leaves a lot of overhead for package users. Therefor, a new enum is added with the latest name for countries, currencies and languages, that can be used instead of enum keys. Keys will not change to keep this package backwards compatible:

/**
 * @source https://www.iso.org/obp/ui/#search/code/
 */
enum ISO3166_1_Name: string
{
    case Turkey = 'Türkiye';
    // Enum key is unchanged to be backwards compatible
}

Methods are added to get the name corresponding to alpha2, alpha3 and numeric values:

$turkiye = ISO3166_1_Alpha_2::fromValue('TR');
$name = $turkiye->toISO3166_Name()->value(); // Türkiye

Helper methods for casing and numeric values as integers

All alpha2 and alpha3 values in ISO3166 and ISO4127 are uppercase, and lowercase in ISO639. You may want to get them as lowercase and uppercase respectfully. Methods to get these values are now available:

$netherlands = ISO3166_1_Alpha_2::fromValue('NL');
$netherlandsLowerCase = $netherlands->lowerCaseValue(); // nl
$dutchFlemish = ISO639_1_Alpha_2::fromValue('nl');
$dutchFlemishUpperCase = $dutchFlemish->upperCaseValue(): // NL

Numeric enums sometimes have leading zeros that are required as their complete value. You may want to get those values as integers though;

$euro = ISO4217_Numeric::fromValue('978');
$euro = ISO4217_Numeric::fromInt(978);
$euroAsInt = $euro->valueAsInt(): // 978

Other changes

Apart from these changes, a lot has been done to improve this package's stability and make this package more mature;

Full Changelog: https://github.com/PrinsFrank/standards/compare/v1.0.0...v1.1.0

standards - v1.0.0 - First stable release

Published by PrinsFrank over 2 years ago

What's Changed

With version 1.0.0, this package is now stable! As the standards are now pulled daily from their respective sources, this package will be updated as soon as their counterpart spec updates! Unfortunately, when pulling from the official sources it became apparent that the 0.0.1 release contained several enum keys that were not consistent with the official spec. make sure to follow the upgrade guide to implement these changes and get up and running with this new release!

New Contributors

Full Changelog: https://github.com/PrinsFrank/standards/compare/v0.0.1...v1.0.0

standards - v0.0.1 Initial release

Published by PrinsFrank over 2 years ago