From d7e2faae20e07a6b844ed1dfba908e67f0c672c6 Mon Sep 17 00:00:00 2001 From: PrinsFrank Date: Wed, 22 Mar 2023 21:47:43 +0100 Subject: [PATCH] Rename currency codes for readability --- .../Currency/ISO4217_Alpha_3_Source.php | 4 ++-- .../Currency/ISO4217_Name_Source.php | 8 +++---- .../Currency/ISO4217_Numeric_Source.php | 4 ++-- ...ISO4217_Alpha_3.php => CurrencyAlpha3.php} | 10 ++++---- .../{ISO4217_Name.php => CurrencyName.php} | 10 ++++---- ...SO4217_Numeric.php => CurrencyNumeric.php} | 10 ++++---- .../{Symbol.php => CurrencySymbol.php} | 2 +- ...Alpha_3Test.php => CurrencyAlpha3Test.php} | 16 ++++++------- ...4217_NameTest.php => CurrencyNameTest.php} | 14 +++++------ ...umericTest.php => CurrencyNumericTest.php} | 24 +++++++++---------- 10 files changed, 51 insertions(+), 51 deletions(-) rename src/Currency/{ISO4217_Alpha_3.php => CurrencyAlpha3.php} (98%) rename src/Currency/{ISO4217_Name.php => CurrencyName.php} (98%) rename src/Currency/{ISO4217_Numeric.php => CurrencyNumeric.php} (98%) rename src/Currency/{Symbol.php => CurrencySymbol.php} (98%) rename tests/Unit/Currency/{ISO4217_Alpha_3Test.php => CurrencyAlpha3Test.php} (70%) rename tests/Unit/Currency/{ISO4217_NameTest.php => CurrencyNameTest.php} (74%) rename tests/Unit/Currency/{ISO4217_NumericTest.php => CurrencyNumericTest.php} (69%) diff --git a/dev/DataSource/Currency/ISO4217_Alpha_3_Source.php b/dev/DataSource/Currency/ISO4217_Alpha_3_Source.php index c9197b06..00f09dc3 100644 --- a/dev/DataSource/Currency/ISO4217_Alpha_3_Source.php +++ b/dev/DataSource/Currency/ISO4217_Alpha_3_Source.php @@ -3,7 +3,7 @@ namespace PrinsFrank\Standards\Dev\DataSource\Currency; -use PrinsFrank\Standards\Currency\ISO4217_Alpha_3; +use PrinsFrank\Standards\Currency\CurrencyAlpha3; use PrinsFrank\Standards\Dev\DataSource\XmlDataSource; use Symfony\Component\Panther\Client; use Symfony\Component\Panther\DomCrawler\Crawler; @@ -42,7 +42,7 @@ public static function transformValue(string $value): string|int|null public static function getSpecFQN(): string { - return ISO4217_Alpha_3::class; + return CurrencyAlpha3::class; } public static function getKeyEnumFQN(): string diff --git a/dev/DataSource/Currency/ISO4217_Name_Source.php b/dev/DataSource/Currency/ISO4217_Name_Source.php index d2757772..ab2aa933 100644 --- a/dev/DataSource/Currency/ISO4217_Name_Source.php +++ b/dev/DataSource/Currency/ISO4217_Name_Source.php @@ -3,8 +3,8 @@ namespace PrinsFrank\Standards\Dev\DataSource\Currency; -use PrinsFrank\Standards\Currency\ISO4217_Alpha_3; -use PrinsFrank\Standards\Currency\ISO4217_Name; +use PrinsFrank\Standards\Currency\CurrencyAlpha3; +use PrinsFrank\Standards\Currency\CurrencyName; use PrinsFrank\Standards\Dev\DataSource\XmlDataSource; use Symfony\Component\Panther\Client; use Symfony\Component\Panther\DomCrawler\Crawler; @@ -43,12 +43,12 @@ public static function transformValue(string $value): string|int|null public static function getSpecFQN(): string { - return ISO4217_Name::class; + return CurrencyName::class; } public static function getKeyEnumFQN(): string { - return ISO4217_Alpha_3::class; + return CurrencyAlpha3::class; } public static function afterPageLoad(Client $client, Crawler $crawler): void diff --git a/dev/DataSource/Currency/ISO4217_Numeric_Source.php b/dev/DataSource/Currency/ISO4217_Numeric_Source.php index a2434023..b700ee10 100644 --- a/dev/DataSource/Currency/ISO4217_Numeric_Source.php +++ b/dev/DataSource/Currency/ISO4217_Numeric_Source.php @@ -3,7 +3,7 @@ namespace PrinsFrank\Standards\Dev\DataSource\Currency; -use PrinsFrank\Standards\Currency\ISO4217_Numeric; +use PrinsFrank\Standards\Currency\CurrencyNumeric; use PrinsFrank\Standards\Dev\DataSource\XmlDataSource; use Symfony\Component\Panther\Client; use Symfony\Component\Panther\DomCrawler\Crawler; @@ -42,7 +42,7 @@ public static function transformValue(string $value): string|int|null public static function getSpecFQN(): string { - return ISO4217_Numeric::class; + return CurrencyNumeric::class; } public static function getKeyEnumFQN(): string diff --git a/src/Currency/ISO4217_Alpha_3.php b/src/Currency/CurrencyAlpha3.php similarity index 98% rename from src/Currency/ISO4217_Alpha_3.php rename to src/Currency/CurrencyAlpha3.php index 5fba01c3..8a92ea28 100644 --- a/src/Currency/ISO4217_Alpha_3.php +++ b/src/Currency/CurrencyAlpha3.php @@ -10,7 +10,7 @@ * @source https://www.six-group.com/en/products-services/financial-information/data-standards.html * @source https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list_one.xml */ -enum ISO4217_Alpha_3: string +enum CurrencyAlpha3: string { case ADB_Unit_of_Account = 'XUA'; case Afghani = 'AFN'; @@ -194,14 +194,14 @@ enum ISO4217_Alpha_3: string /** @deprecated Has been removed from the specification but is maintained here for Backwards Compatibility reasons */ case Kuna = 'HRK'; - public function toISO4217_Numeric(): ISO4217_Numeric + public function toCurrencyNumeric(): CurrencyNumeric { - return BackedEnum::fromKey(ISO4217_Numeric::class, $this->name); + return BackedEnum::fromKey(CurrencyNumeric::class, $this->name); } - public function toISO4217_Name(): ISO4217_Name + public function toCurrencyName(): CurrencyName { - return BackedEnum::fromKey(ISO4217_Name::class, $this->name); + return BackedEnum::fromKey(CurrencyName::class, $this->name); } public function lowerCaseValue(): string diff --git a/src/Currency/ISO4217_Name.php b/src/Currency/CurrencyName.php similarity index 98% rename from src/Currency/ISO4217_Name.php rename to src/Currency/CurrencyName.php index a84c3eaa..f0836791 100644 --- a/src/Currency/ISO4217_Name.php +++ b/src/Currency/CurrencyName.php @@ -10,7 +10,7 @@ * @source https://www.six-group.com/en/products-services/financial-information/data-standards.html * @source https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list_one.xml */ -enum ISO4217_Name: string +enum CurrencyName: string { case ADB_Unit_of_Account = 'ADB Unit of Account'; case Afghani = 'Afghani'; @@ -194,13 +194,13 @@ enum ISO4217_Name: string /** @deprecated Has been removed from the specification but is maintained here for Backwards Compatibility reasons */ case Kuna = 'Kuna'; - public function toISO4217_Alpha_3(): ISO4217_Alpha_3 + public function toCurrencyAlpha3(): CurrencyAlpha3 { - return BackedEnum::fromKey(ISO4217_Alpha_3::class, $this->name); + return BackedEnum::fromKey(CurrencyAlpha3::class, $this->name); } - public function toISO4217_Numeric(): ISO4217_Numeric + public function toCurrencyNumeric(): CurrencyNumeric { - return BackedEnum::fromKey(ISO4217_Numeric::class, $this->name); + return BackedEnum::fromKey(CurrencyNumeric::class, $this->name); } } diff --git a/src/Currency/ISO4217_Numeric.php b/src/Currency/CurrencyNumeric.php similarity index 98% rename from src/Currency/ISO4217_Numeric.php rename to src/Currency/CurrencyNumeric.php index f9786943..654cbbb2 100644 --- a/src/Currency/ISO4217_Numeric.php +++ b/src/Currency/CurrencyNumeric.php @@ -10,7 +10,7 @@ * @source https://www.six-group.com/en/products-services/financial-information/data-standards.html * @source https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list_one.xml */ -enum ISO4217_Numeric: string +enum CurrencyNumeric: string { case ADB_Unit_of_Account = '965'; case Afghani = '971'; @@ -204,14 +204,14 @@ public static function tryFromInt(int $from): ?self return self::tryFrom(str_pad((string) $from, 3, '0', STR_PAD_LEFT)); } - public function toISO4217_Alpha_3(): ISO4217_Alpha_3 + public function toCurrencyAlpha3(): CurrencyAlpha3 { - return BackedEnum::fromKey(ISO4217_Alpha_3::class, $this->name); + return BackedEnum::fromKey(CurrencyAlpha3::class, $this->name); } - public function toISO4217_Name(): ISO4217_Name + public function toCurrencyName(): CurrencyName { - return BackedEnum::fromKey(ISO4217_Name::class, $this->name); + return BackedEnum::fromKey(CurrencyName::class, $this->name); } public function valueAsInt(): int diff --git a/src/Currency/Symbol.php b/src/Currency/CurrencySymbol.php similarity index 98% rename from src/Currency/Symbol.php rename to src/Currency/CurrencySymbol.php index f625de84..467e1820 100644 --- a/src/Currency/Symbol.php +++ b/src/Currency/CurrencySymbol.php @@ -3,7 +3,7 @@ namespace PrinsFrank\Standards\Currency; -enum Symbol: string +enum CurrencySymbol: string { case Afghani = '؋'; case Armenian_Dram = '֏'; diff --git a/tests/Unit/Currency/ISO4217_Alpha_3Test.php b/tests/Unit/Currency/CurrencyAlpha3Test.php similarity index 70% rename from tests/Unit/Currency/ISO4217_Alpha_3Test.php rename to tests/Unit/Currency/CurrencyAlpha3Test.php index 88a527f6..3620b263 100644 --- a/tests/Unit/Currency/ISO4217_Alpha_3Test.php +++ b/tests/Unit/Currency/CurrencyAlpha3Test.php @@ -4,24 +4,24 @@ namespace PrinsFrank\Standards\Tests\Unit\Currency; use PHPUnit\Framework\TestCase; -use PrinsFrank\Standards\Currency\ISO4217_Alpha_3; +use PrinsFrank\Standards\Currency\CurrencyAlpha3; use TypeError; /** - * @coversDefaultClass \PrinsFrank\Standards\Currency\ISO4217_Alpha_3 + * @coversDefaultClass \PrinsFrank\Standards\Currency\CurrencyAlpha3 */ -class ISO4217_Alpha_3Test extends TestCase +class CurrencyAlpha3Test extends TestCase { /** * @covers ::toISO4217_Numeric */ public function testAllCasesCanBeConvertedToISO4217Numeric(): void { - $cases = ISO4217_Alpha_3::cases(); + $cases = CurrencyAlpha3::cases(); static::assertNotEmpty($cases); foreach ($cases as $case) { try { - $case->toISO4217_Numeric(); + $case->toCurrencyNumeric(); } catch (TypeError) { $this->fail(sprintf('Case %s could not be converted to ISO4217_Numeric', $case->name)); } @@ -33,11 +33,11 @@ public function testAllCasesCanBeConvertedToISO4217Numeric(): void */ public function testAllCasesCanBeConvertedToISO4217Name(): void { - $cases = ISO4217_Alpha_3::cases(); + $cases = CurrencyAlpha3::cases(); static::assertNotEmpty($cases); foreach ($cases as $case) { try { - $case->toISO4217_Name(); + $case->toCurrencyName(); } catch (TypeError) { $this->fail(sprintf('Case %s could not be converted to ISO4217_Name', $case->name)); } @@ -49,6 +49,6 @@ public function testAllCasesCanBeConvertedToISO4217Name(): void */ public function testLowerCaseValue(): void { - static::assertSame('xua', ISO4217_Alpha_3::ADB_Unit_of_Account->lowerCaseValue()); + static::assertSame('xua', CurrencyAlpha3::ADB_Unit_of_Account->lowerCaseValue()); } } diff --git a/tests/Unit/Currency/ISO4217_NameTest.php b/tests/Unit/Currency/CurrencyNameTest.php similarity index 74% rename from tests/Unit/Currency/ISO4217_NameTest.php rename to tests/Unit/Currency/CurrencyNameTest.php index d4b17d94..08ba3667 100644 --- a/tests/Unit/Currency/ISO4217_NameTest.php +++ b/tests/Unit/Currency/CurrencyNameTest.php @@ -4,24 +4,24 @@ namespace PrinsFrank\Standards\Tests\Unit\Currency; use PHPUnit\Framework\TestCase; -use PrinsFrank\Standards\Currency\ISO4217_Name; +use PrinsFrank\Standards\Currency\CurrencyName; use TypeError; /** - * @coversDefaultClass \PrinsFrank\Standards\Currency\ISO4217_Name + * @coversDefaultClass \PrinsFrank\Standards\Currency\CurrencyName */ -class ISO4217_NameTest extends TestCase +class CurrencyNameTest extends TestCase { /** * @covers ::toISO4217_Numeric */ public function testAllCasesCanBeConvertedToISO4217Numeric(): void { - $cases = ISO4217_Name::cases(); + $cases = CurrencyName::cases(); static::assertNotEmpty($cases); foreach ($cases as $case) { try { - $case->toISO4217_Numeric(); + $case->toCurrencyNumeric(); } catch (TypeError) { $this->fail(sprintf('Case %s could not be converted to ISO4217_Numeric', $case->name)); } @@ -33,11 +33,11 @@ public function testAllCasesCanBeConvertedToISO4217Numeric(): void */ public function testAllCasesCanBeConvertedToISO4217Alpha3(): void { - $cases = ISO4217_Name::cases(); + $cases = CurrencyName::cases(); static::assertNotEmpty($cases); foreach ($cases as $case) { try { - $case->toISO4217_Alpha_3(); + $case->toCurrencyAlpha3(); } catch (TypeError) { $this->fail(sprintf('Case %s could not be converted to ISO4217_Alpha3', $case->name)); } diff --git a/tests/Unit/Currency/ISO4217_NumericTest.php b/tests/Unit/Currency/CurrencyNumericTest.php similarity index 69% rename from tests/Unit/Currency/ISO4217_NumericTest.php rename to tests/Unit/Currency/CurrencyNumericTest.php index 5a5146da..5eadf856 100644 --- a/tests/Unit/Currency/ISO4217_NumericTest.php +++ b/tests/Unit/Currency/CurrencyNumericTest.php @@ -4,25 +4,25 @@ namespace PrinsFrank\Standards\Tests\Unit\Currency; use PHPUnit\Framework\TestCase; -use PrinsFrank\Standards\Currency\ISO4217_Numeric; +use PrinsFrank\Standards\Currency\CurrencyNumeric; use TypeError; use ValueError; /** - * @coversDefaultClass \PrinsFrank\Standards\Currency\ISO4217_Numeric + * @coversDefaultClass \PrinsFrank\Standards\Currency\CurrencyNumeric */ -class ISO4217_NumericTest extends TestCase +class CurrencyNumericTest extends TestCase { /** * @covers ::toISO4217_Alpha_3 */ public function testAllCasesCanBeConvertedToISO4217Alpha3(): void { - $cases = ISO4217_Numeric::cases(); + $cases = CurrencyNumeric::cases(); static::assertNotEmpty($cases); foreach ($cases as $case) { try { - $case->toISO4217_Alpha_3(); + $case->toCurrencyAlpha3(); } catch (TypeError) { $this->fail(sprintf('Case %s could not be converted to ISO4217_Alpha3', $case->name)); } @@ -34,11 +34,11 @@ public function testAllCasesCanBeConvertedToISO4217Alpha3(): void */ public function testAllCasesCanBeConvertedToISO4217Name(): void { - $cases = ISO4217_Numeric::cases(); + $cases = CurrencyNumeric::cases(); static::assertNotEmpty($cases); foreach ($cases as $case) { try { - $case->toISO4217_Name(); + $case->toCurrencyName(); } catch (TypeError) { $this->fail(sprintf('Case %s could not be converted to ISO4217_Name', $case->name)); } @@ -50,7 +50,7 @@ public function testAllCasesCanBeConvertedToISO4217Name(): void */ public function testFromInt(): void { - static::assertEquals(ISO4217_Numeric::Lek, ISO4217_Numeric::fromInt(8)); + static::assertEquals(CurrencyNumeric::Lek, CurrencyNumeric::fromInt(8)); } /** @@ -59,7 +59,7 @@ public function testFromInt(): void public function testFromIntThrowsExceptionOnNonExistingValue(): void { $this->expectException(ValueError::class); - static::assertNull(ISO4217_Numeric::fromInt(1)); + static::assertNull(CurrencyNumeric::fromInt(1)); } /** @@ -67,8 +67,8 @@ public function testFromIntThrowsExceptionOnNonExistingValue(): void */ public function testTryFromInt(): void { - static::assertEquals(ISO4217_Numeric::Lek, ISO4217_Numeric::tryFromInt(8)); - static::assertNull(ISO4217_Numeric::tryFromInt(1)); + static::assertEquals(CurrencyNumeric::Lek, CurrencyNumeric::tryFromInt(8)); + static::assertNull(CurrencyNumeric::tryFromInt(1)); } /** @@ -76,6 +76,6 @@ public function testTryFromInt(): void */ public function testValueAsInt(): void { - static::assertSame(965, ISO4217_Numeric::ADB_Unit_of_Account->valueAsInt()); + static::assertSame(965, CurrencyNumeric::ADB_Unit_of_Account->valueAsInt()); } }