Skip to content

Commit

Permalink
Rename currency codes for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinsFrank committed Mar 22, 2023
1 parent d12f90f commit d7e2faa
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions dev/DataSource/Currency/ISO4217_Alpha_3_Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions dev/DataSource/Currency/ISO4217_Name_Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dev/DataSource/Currency/ISO4217_Numeric_Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/Currency/ISO4217_Name.php → src/Currency/CurrencyName.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace PrinsFrank\Standards\Currency;

enum Symbol: string
enum CurrencySymbol: string
{
case Afghani = '؋';
case Armenian_Dram = '֏';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand All @@ -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));
}

/**
Expand All @@ -59,23 +59,23 @@ public function testFromInt(): void
public function testFromIntThrowsExceptionOnNonExistingValue(): void
{
$this->expectException(ValueError::class);
static::assertNull(ISO4217_Numeric::fromInt(1));
static::assertNull(CurrencyNumeric::fromInt(1));
}

/**
* @covers ::tryFromInt
*/
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));
}

/**
* @covers ::valueAsInt
*/
public function testValueAsInt(): void
{
static::assertSame(965, ISO4217_Numeric::ADB_Unit_of_Account->valueAsInt());
static::assertSame(965, CurrencyNumeric::ADB_Unit_of_Account->valueAsInt());
}
}

0 comments on commit d7e2faa

Please sign in to comment.