Skip to content

Commit

Permalink
Add short country code source setup
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinsFrank committed Mar 19, 2023
1 parent a6ce2cd commit 23db17b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev/DataSource/SpecType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
enum SpecType
{
case COUNTRY;
case COUNTRY_SHORT;
case CURRENCY;
case HTTP_STATUS_CODES;
case HTTP_METHODS;
Expand Down
13 changes: 13 additions & 0 deletions dev/SpecUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
use PrinsFrank\Standards\Dev\DataSource\Country\ISO3166_1_Alpha_3_Source;
use PrinsFrank\Standards\Dev\DataSource\Country\ISO3166_1_Name_Source;
use PrinsFrank\Standards\Dev\DataSource\Country\ISO3166_1_Numeric_Source;
use PrinsFrank\Standards\Dev\DataSource\CountryShort\CountryAlpha2Source;
use PrinsFrank\Standards\Dev\DataSource\CountryShort\CountryAlpha3Source;
use PrinsFrank\Standards\Dev\DataSource\CountryShort\CountryNameSource;
use PrinsFrank\Standards\Dev\DataSource\CountryShort\CountryNumericSource;
use PrinsFrank\Standards\Dev\DataSource\Currency\ISO4217_Alpha_3_Source;
use PrinsFrank\Standards\Dev\DataSource\Currency\ISO4217_Name_Source;
use PrinsFrank\Standards\Dev\DataSource\Currency\ISO4217_Numeric_Source;
Expand Down Expand Up @@ -41,6 +45,14 @@ class SpecUpdater
ISO3166_1_Name_Source::class,
];

/** @var array<class-string<DataSource>> */
public const COUNTRY_SHORT_SOURCES = [
CountryNumericSource::class,
CountryAlpha2Source::class,
CountryAlpha3Source::class,
CountryNameSource::class,
];

/** @var array<class-string<DataSource>> */
public const CURRENCY_SOURCES = [
ISO4217_Alpha_3_Source::class,
Expand Down Expand Up @@ -79,6 +91,7 @@ public static function update(Event $event): void

$sources = match (UnitEnum::tryFromKey(SpecType::class, strtoupper(str_replace('-', '_', $type)))) {
SpecType::COUNTRY => self::COUNTRY_SOURCES,
SpecType::COUNTRY_SHORT => self::COUNTRY_SHORT_SOURCES,
SpecType::CURRENCY => self::CURRENCY_SOURCES,
SpecType::HTTP_STATUS_CODES => self::HTTP_STATUS_CODE_SOURCES,
SpecType::HTTP_METHODS => self::HTTP_METHOD_SOURCES,
Expand Down

0 comments on commit 23db17b

Please sign in to comment.