Skip to content

Commit

Permalink
Rename conversion methods
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinsFrank committed Mar 19, 2023
1 parent f56d864 commit 51f1034
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 59 deletions.
6 changes: 3 additions & 3 deletions src/CountryShort/CountryAlpha2.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,17 @@ enum CountryAlpha2: string
case Zambia = 'ZM';
case Zimbabwe = 'ZW';

public function toISO3166_1_Alpha_3(): CountryAlpha3
public function toCountryAlpha3(): CountryAlpha3
{
return BackedEnum::fromKey(CountryAlpha3::class, $this->name);
}

public function toISO3166_1_Numeric(): CountryNumeric
public function toCountryNumeric(): CountryNumeric
{
return BackedEnum::fromKey(CountryNumeric::class, $this->name);
}

public function toISO3166_Name(): CountryName
public function toCountryName(): CountryName
{
return BackedEnum::fromKey(CountryName::class, $this->name);
}
Expand Down
6 changes: 3 additions & 3 deletions src/CountryShort/CountryAlpha3.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,17 @@ enum CountryAlpha3: string
case Zambia = 'ZMB';
case Zimbabwe = 'ZWE';

public function toISO3166_1_Alpha_2(): CountryAlpha2
public function toCountryAlpha2(): CountryAlpha2
{
return BackedEnum::fromKey(CountryAlpha2::class, $this->name);
}

public function toISO3166_1_Numeric(): CountryNumeric
public function toCountryNumeric(): CountryNumeric
{
return BackedEnum::fromKey(CountryNumeric::class, $this->name);
}

public function toISO3166_Name(): CountryName
public function toCountryName(): CountryName
{
return BackedEnum::fromKey(CountryName::class, $this->name);
}
Expand Down
6 changes: 3 additions & 3 deletions src/CountryShort/CountryName.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,17 @@ enum CountryName: string
case Zambia = 'Zambia';
case Zimbabwe = 'Zimbabwe';

public function toISO3166_1_Alpha_2(): CountryAlpha2
public function toCountryAlpha2(): CountryAlpha2
{
return BackedEnum::fromKey(CountryAlpha2::class, $this->name);
}

public function toISO3166_1_Alpha_3(): CountryAlpha3
public function toCountryAlpha3(): CountryAlpha3
{
return BackedEnum::fromKey(CountryAlpha3::class, $this->name);
}

public function toISO3166_1_Numeric(): CountryNumeric
public function toCountryNumeric(): CountryNumeric
{
return BackedEnum::fromKey(CountryNumeric::class, $this->name);
}
Expand Down
6 changes: 3 additions & 3 deletions src/CountryShort/CountryNumeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,17 +270,17 @@ public static function tryFromInt(int $from): ?self
return self::tryFrom(str_pad((string) $from, 3, '0', STR_PAD_LEFT));
}

public function toISO3166_1_Alpha_2(): CountryAlpha2
public function toCountryAlpha2(): CountryAlpha2
{
return BackedEnum::fromKey(CountryAlpha2::class, $this->name);
}

public function toISO3166_1_Alpha_3(): CountryAlpha3
public function toCountryAlpha3(): CountryAlpha3
{
return BackedEnum::fromKey(CountryAlpha3::class, $this->name);
}

public function toISO3166_Name(): CountryName
public function toCountryName(): CountryName
{
return BackedEnum::fromKey(CountryName::class, $this->name);
}
Expand Down
24 changes: 12 additions & 12 deletions tests/Unit/CountryShort/CountryAlpha2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,49 @@
class CountryAlpha2Test extends TestCase
{
/**
* @covers ::toISO3166_1_Alpha_3
* @covers ::toCountryAlpha3
*/
public function testAllCasesCanBeConvertedToISO3166Alpha3(): void
public function testAllCasesCanBeConvertedToCountryAlpha3(): void
{
$cases = CountryAlpha2::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_1_Alpha_3();
$case->toCountryAlpha3();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_3', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryAlpha3', $case->name));
}
}
}

/**
* @covers ::toISO3166_1_Numeric
* @covers ::toCountryNumeric
*/
public function testAllCasesCanBeConvertedToISO3166Numeric(): void
public function testAllCasesCanBeConvertedToCountryNumeric(): void
{
$cases = CountryAlpha2::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_1_Numeric();
$case->toCountryNumeric();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Numeric', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryNumeric', $case->name));
}
}
}

/**
* @covers ::toISO3166_Name
* @covers ::toCountryName
*/
public function testAllCasesCanBeConvertedToISO3166Name(): void
public function testAllCasesCanBeConvertedToCountryName(): void
{
$cases = CountryAlpha2::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_Name();
$case->toCountryName();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Name', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryName', $case->name));
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions tests/Unit/CountryShort/CountryAlpha3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,49 @@
class CountryAlpha3Test extends TestCase
{
/**
* @covers ::toISO3166_1_Alpha_2
* @covers ::toCountryAlpha2
*/
public function testAllCasesCanBeConvertedToISO3166Alpha2(): void
public function testAllCasesCanBeConvertedToCountryAlpha2(): void
{
$cases = CountryAlpha3::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_1_Alpha_2();
$case->toCountryAlpha2();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_2', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryAlpha2', $case->name));
}
}
}

/**
* @covers ::toISO3166_1_Numeric
* @covers ::toCountryNumeric
*/
public function testAllCasesCanBeConvertedToISO3166Numeric(): void
public function testAllCasesCanBeConvertedToCountryNumeric(): void
{
$cases = CountryAlpha3::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_1_Numeric();
$case->toCountryNumeric();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Numeric', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryNumeric', $case->name));
}
}
}

/**
* @covers ::toISO3166_Name
* @covers ::toCountryName
*/
public function testAllCasesCanBeConvertedToISO3166Name(): void
public function testAllCasesCanBeConvertedToCountryName(): void
{
$cases = CountryAlpha3::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_Name();
$case->toCountryName();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Name', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryName', $case->name));
}
}
}
Expand Down
22 changes: 11 additions & 11 deletions tests/Unit/CountryShort/CountryNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,54 @@
use TypeError;

/**
* @coversDefaultClass \PrinsFrank\Standards\Country\ISO3166_1_Name
* @coversDefaultClass \PrinsFrank\Standards\CountryShort\CountryName
*/
class CountryNameTest extends TestCase
{
/**
* @covers ::toISO3166_1_Alpha_2
* @covers ::toCountryAlpha2
*/
public function testAllCasesCanBeConvertedToISO3166Alpha2(): void
public function testAllCasesCanBeConvertedToCountryAlpha2(): void
{
$cases = CountryName::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_1_Alpha_2();
$case->toCountryAlpha2();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_2', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryAlpha2', $case->name));
}
}
}

/**
* @covers ::toISO3166_1_Alpha_3
* @covers ::toCountryAlpha3
*/
public function testAllCasesCanBeConvertedToISO3166Alpha3(): void
{
$cases = CountryName::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_1_Alpha_3();
$case->toCountryAlpha3();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_3', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryAlpha3', $case->name));
}
}
}

/**
* @covers ::toISO3166_1_Numeric
* @covers ::toCountryNumeric
*/
public function testAllCasesCanBeConvertedToISO3166Numeric(): void
{
$cases = CountryName::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_1_Numeric();
$case->toCountryNumeric();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Numeric', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryNumeric', $case->name));
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions tests/Unit/CountryShort/CountryNumericTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,49 @@
class CountryNumericTest extends TestCase
{
/**
* @covers ::toISO3166_1_Alpha_2
* @covers ::toCountryAlpha2
*/
public function testAllCasesCanBeConvertedToISO3166Alpha2(): void
public function testAllCasesCanBeConvertedToCountryAlpha2(): void
{
$cases = CountryNumeric::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_1_Alpha_2();
$case->toCountryAlpha2();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_2', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryAlpha2', $case->name));
}
}
}

/**
* @covers ::toISO3166_1_Alpha_3
* @covers ::toCountryAlpha3
*/
public function testAllCasesCanBeConvertedToISO3166Alpha3(): void
public function testAllCasesCanBeConvertedToCountryAlpha3(): void
{
$cases = CountryNumeric::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_1_Alpha_3();
$case->toCountryAlpha3();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Alpha_3', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryAlpha3', $case->name));
}
}
}

/**
* @covers ::toISO3166_Name
* @covers ::toCountryName
*/
public function testAllCasesCanBeConvertedToISO3166Name(): void
public function testAllCasesCanBeConvertedToCountryName(): void
{
$cases = CountryNumeric::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
try {
$case->toISO3166_Name();
$case->toCountryName();
} catch (TypeError) {
$this->fail(sprintf('Case %s could not be converted to ISO3166_1_Name', $case->name));
$this->fail(sprintf('Case %s could not be converted to CountryName', $case->name));
}
}
}
Expand Down

0 comments on commit 51f1034

Please sign in to comment.