Skip to content

Commit

Permalink
Rename language enmus for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinsFrank committed Mar 22, 2023
1 parent 7c2ff92 commit a305356
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 101 deletions.
4 changes: 2 additions & 2 deletions dev/DataSource/Language/ISO639_1_Alpha_2_Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace PrinsFrank\Standards\Dev\DataSource\Language;

use PrinsFrank\Standards\Dev\DataSource\HtmlDataSource;
use PrinsFrank\Standards\Language\ISO639_1_Alpha_2;
use PrinsFrank\Standards\Language\LanguageAlpha2;
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 ISO639_1_Alpha_2::class;
return LanguageAlpha2::class;
}

public static function getKeyEnumFQN(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace PrinsFrank\Standards\Dev\DataSource\Language;

use PrinsFrank\Standards\Dev\DataSource\HtmlDataSource;
use PrinsFrank\Standards\Language\ISO639_2_Alpha_3_Bibliographic;
use PrinsFrank\Standards\Language\LanguageAlpha3Bibliographic;
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

Expand Down Expand Up @@ -48,7 +48,7 @@ public static function transformValue(string $value): string|int|null

public static function getSpecFQN(): string
{
return ISO639_2_Alpha_3_Bibliographic::class;
return LanguageAlpha3Bibliographic::class;
}

public static function getKeyEnumFQN(): string
Expand Down
4 changes: 2 additions & 2 deletions dev/DataSource/Language/ISO639_2_Alpha_3_Common_Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace PrinsFrank\Standards\Dev\DataSource\Language;

use PrinsFrank\Standards\Dev\DataSource\HtmlDataSource;
use PrinsFrank\Standards\Language\ISO639_2_Alpha_3_Common;
use PrinsFrank\Standards\Language\LanguageAlpha3Common;
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

Expand Down Expand Up @@ -46,7 +46,7 @@ public static function transformValue(string $value): string|int|null

public static function getSpecFQN(): string
{
return ISO639_2_Alpha_3_Common::class;
return LanguageAlpha3Common::class;
}

public static function getKeyEnumFQN(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace PrinsFrank\Standards\Dev\DataSource\Language;

use PrinsFrank\Standards\Dev\DataSource\HtmlDataSource;
use PrinsFrank\Standards\Language\ISO639_2_Alpha_3_Terminology;
use PrinsFrank\Standards\Language\LanguageAlpha3Terminology;
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

Expand Down Expand Up @@ -48,7 +48,7 @@ public static function transformValue(string $value): string|int|null

public static function getSpecFQN(): string
{
return ISO639_2_Alpha_3_Terminology::class;
return LanguageAlpha3Terminology::class;
}

public static function getKeyEnumFQN(): string
Expand Down
8 changes: 4 additions & 4 deletions dev/DataSource/Language/ISO639_Name_Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
namespace PrinsFrank\Standards\Dev\DataSource\Language;

use PrinsFrank\Standards\Dev\DataSource\HtmlDataSource;
use PrinsFrank\Standards\Language\ISO639_2_Alpha_3_Common;
use PrinsFrank\Standards\Language\ISO639_Name;
use PrinsFrank\Standards\Language\LanguageAlpha3Common;
use PrinsFrank\Standards\Language\LanguageName;
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

Expand Down Expand Up @@ -47,12 +47,12 @@ public static function transformValue(string $value): string|int|null

public static function getSpecFQN(): string
{
return ISO639_Name::class;
return LanguageName::class;
}

public static function getKeyEnumFQN(): string
{
return ISO639_2_Alpha_3_Common::class;
return LanguageAlpha3Common::class;
}

public static function afterPageLoad(Client $client, Crawler $crawler): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @source https://www.iso.org/iso-639-language-codes.html
* @source http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
enum ISO639_1_Alpha_2: string
enum LanguageAlpha2: string
{
case Abkhazian = 'ab';
case Afar = 'aa';
Expand Down Expand Up @@ -196,19 +196,19 @@ enum ISO639_1_Alpha_2: string
case Zhuang_Chuang = 'za';
case Zulu = 'zu';

public function toISO639_2_Alpha_3_Bibliographic(): ISO639_2_Alpha_3_Common|ISO639_2_Alpha_3_Bibliographic|null
public function toLanguageAlpha3Bibliographic(): LanguageAlpha3Common|LanguageAlpha3Bibliographic|null
{
return BackedEnum::tryFromKey(ISO639_2_Alpha_3_Common::class, $this->name) ?? BackedEnum::tryFromKey(ISO639_2_Alpha_3_Bibliographic::class, $this->name) ?? null;
return BackedEnum::tryFromKey(LanguageAlpha3Common::class, $this->name) ?? BackedEnum::tryFromKey(LanguageAlpha3Bibliographic::class, $this->name) ?? null;
}

public function toISO639_2_Alpha_3_Terminology(): ISO639_2_Alpha_3_Common|ISO639_2_Alpha_3_Terminology|null
public function toLanguageAlpha3Terminology(): LanguageAlpha3Common|LanguageAlpha3Terminology|null
{
return BackedEnum::tryFromKey(ISO639_2_Alpha_3_Common::class, $this->name) ?? BackedEnum::tryFromKey(ISO639_2_Alpha_3_Terminology::class, $this->name) ?? null;
return BackedEnum::tryFromKey(LanguageAlpha3Common::class, $this->name) ?? BackedEnum::tryFromKey(LanguageAlpha3Terminology::class, $this->name) ?? null;
}

public function toISO639_Name(): ISO639_Name
public function toLanguageName(): LanguageName
{
return BackedEnum::fromKey(ISO639_Name::class, $this->name);
return BackedEnum::fromKey(LanguageName::class, $this->name);
}

public function upperCaseValue(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @source https://www.iso.org/iso-639-language-codes.html
* @source http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
enum ISO639_2_Alpha_3_Bibliographic: string
enum LanguageAlpha3Bibliographic: string
{
case Albanian = 'alb';
case Armenian = 'arm';
Expand All @@ -32,19 +32,19 @@ enum ISO639_2_Alpha_3_Bibliographic: string
case Tibetan = 'tib';
case Welsh = 'wel';

public function toISO639_2_Alpha_3_Terminology(): ISO639_2_Alpha_3_Common|ISO639_2_Alpha_3_Terminology|null
public function toLanguageAlpha3Terminology(): LanguageAlpha3Common|LanguageAlpha3Terminology|null
{
return BackedEnum::tryFromKey(ISO639_2_Alpha_3_Common::class, $this->name) ?? BackedEnum::tryFromKey(ISO639_2_Alpha_3_Terminology::class, $this->name) ?? null;
return BackedEnum::tryFromKey(LanguageAlpha3Common::class, $this->name) ?? BackedEnum::tryFromKey(LanguageAlpha3Terminology::class, $this->name) ?? null;
}

public function toISO639_1_Alpha_2(): ISO639_1_Alpha_2|null
public function toLanguageAlpha2(): LanguageAlpha2|null
{
return BackedEnum::tryFromKey(ISO639_1_Alpha_2::class, $this->name);
return BackedEnum::tryFromKey(LanguageAlpha2::class, $this->name);
}

public function toISO639_Name(): ISO639_Name
public function toLanguageName(): LanguageName
{
return BackedEnum::fromKey(ISO639_Name::class, $this->name);
return BackedEnum::fromKey(LanguageName::class, $this->name);
}

public function upperCaseValue(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @source https://www.iso.org/iso-639-language-codes.html
* @source http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
enum ISO639_2_Alpha_3_Common: string
enum LanguageAlpha3Common: string
{
case Abkhazian = 'abk';
case Achinese = 'ace';
Expand Down Expand Up @@ -478,14 +478,14 @@ enum ISO639_2_Alpha_3_Common: string
case Zulu = 'zul';
case Zuni = 'zun';

public function toISO639_1_Alpha_2(): ISO639_1_Alpha_2|null
public function toLanguageAlpha2(): LanguageAlpha2|null
{
return BackedEnum::tryFromKey(ISO639_1_Alpha_2::class, $this->name);
return BackedEnum::tryFromKey(LanguageAlpha2::class, $this->name);
}

public function toISO639_Name(): ISO639_Name
public function toLanguageName(): LanguageName
{
return BackedEnum::fromKey(ISO639_Name::class, $this->name);
return BackedEnum::fromKey(LanguageName::class, $this->name);
}

public function upperCaseValue(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @source https://www.iso.org/iso-639-language-codes.html
* @source http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
enum ISO639_2_Alpha_3_Terminology: string
enum LanguageAlpha3Terminology: string
{
case Albanian = 'sqi';
case Armenian = 'hye';
Expand All @@ -32,19 +32,19 @@ enum ISO639_2_Alpha_3_Terminology: string
case Tibetan = 'bod';
case Welsh = 'cym';

public function toISO639_2_Alpha_3_Bibliographic(): ISO639_2_Alpha_3_Common|ISO639_2_Alpha_3_Bibliographic|null
public function toLanguageAlpha3Bibliographic(): LanguageAlpha3Common|LanguageAlpha3Bibliographic|null
{
return BackedEnum::tryFromKey(ISO639_2_Alpha_3_Common::class, $this->name) ?? BackedEnum::tryFromKey(ISO639_2_Alpha_3_Bibliographic::class, $this->name) ?? null;
return BackedEnum::tryFromKey(LanguageAlpha3Common::class, $this->name) ?? BackedEnum::tryFromKey(LanguageAlpha3Bibliographic::class, $this->name) ?? null;
}

public function toISO639_1_Alpha_2(): ISO639_1_Alpha_2|null
public function toLanguageAlpha2(): LanguageAlpha2|null
{
return BackedEnum::tryFromKey(ISO639_1_Alpha_2::class, $this->name);
return BackedEnum::tryFromKey(LanguageAlpha2::class, $this->name);
}

public function toISO639_Name(): ISO639_Name
public function toLanguageName(): LanguageName
{
return BackedEnum::fromKey(ISO639_Name::class, $this->name);
return BackedEnum::fromKey(LanguageName::class, $this->name);
}

public function upperCaseValue(): string
Expand Down
14 changes: 7 additions & 7 deletions src/Language/ISO639_Name.php → src/Language/LanguageName.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @source https://www.iso.org/iso-639-language-codes.html
* @source http://www.loc.gov/standards/iso639-2/php/code_list.php
*/
enum ISO639_Name: string
enum LanguageName: string
{
case Abkhazian = 'Abkhazian';
case Achinese = 'Achinese';
Expand Down Expand Up @@ -498,18 +498,18 @@ enum ISO639_Name: string
case Zulu = 'Zulu';
case Zuni = 'Zuni';

public function toISO639_1_Alpha_2(): ISO639_1_Alpha_2|null
public function toLanguageAlpha2(): LanguageAlpha2|null
{
return BackedEnum::tryFromKey(ISO639_1_Alpha_2::class, $this->name);
return BackedEnum::tryFromKey(LanguageAlpha2::class, $this->name);
}

public function toISO639_2_Alpha_3_Bibliographic(): ISO639_2_Alpha_3_Common|ISO639_2_Alpha_3_Bibliographic|null
public function toLanguageAlpha3Bibliographic(): LanguageAlpha3Common|LanguageAlpha3Bibliographic|null
{
return BackedEnum::tryFromKey(ISO639_2_Alpha_3_Common::class, $this->name) ?? BackedEnum::tryFromKey(ISO639_2_Alpha_3_Bibliographic::class, $this->name) ?? null;
return BackedEnum::tryFromKey(LanguageAlpha3Common::class, $this->name) ?? BackedEnum::tryFromKey(LanguageAlpha3Bibliographic::class, $this->name) ?? null;
}

public function toISO639_2_Alpha_3_Terminology(): ISO639_2_Alpha_3_Common|ISO639_2_Alpha_3_Terminology|null
public function toLanguageAlpha3Terminology(): LanguageAlpha3Common|LanguageAlpha3Terminology|null
{
return BackedEnum::tryFromKey(ISO639_2_Alpha_3_Common::class, $this->name) ?? BackedEnum::tryFromKey(ISO639_2_Alpha_3_Terminology::class, $this->name) ?? null;
return BackedEnum::tryFromKey(LanguageAlpha3Common::class, $this->name) ?? BackedEnum::tryFromKey(LanguageAlpha3Terminology::class, $this->name) ?? null;
}
}
24 changes: 12 additions & 12 deletions tests/Unit/Language/ISO639_1_Alpha_2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@
namespace PrinsFrank\Standards\Tests\Unit\Language;

use PHPUnit\Framework\TestCase;
use PrinsFrank\Standards\Language\ISO639_1_Alpha_2;
use PrinsFrank\Standards\Language\LanguageAlpha2;

/**
* @coversDefaultClass \PrinsFrank\Standards\Language\ISO639_1_Alpha_2
* @coversDefaultClass \PrinsFrank\Standards\Language\LanguageAlpha2
*/
class ISO639_1_Alpha_2Test extends TestCase
{
/**
* @covers ::toISO639_2_Alpha_3_Bibliographic
* @covers ::toLanguageAlpha3Bibliographic
*/
public function testAllCasesCanBeConvertedToToISO392_2Bibliographic(): void
{
$cases = ISO639_1_Alpha_2::cases();
$cases = LanguageAlpha2::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
static::assertNotNull($case->toISO639_2_Alpha_3_Bibliographic());
static::assertNotNull($case->toLanguageAlpha3Bibliographic());
}
}

/**
* @covers ::toISO639_2_Alpha_3_Terminology
* @covers ::toLanguageAlpha3Terminology
*/
public function testAllCasesCanBeConvertedToISO392_2Terminology(): void
{
$cases = ISO639_1_Alpha_2::cases();
$cases = LanguageAlpha2::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
static::assertNotNull($case->toISO639_2_Alpha_3_Terminology());
static::assertNotNull($case->toLanguageAlpha3Terminology());
}
}

/**
* @covers ::toISO639_Name
* @covers ::toLanguageName
*/
public function testAllCasesCanBeConvertedToISO392_Name(): void
{
$cases = ISO639_1_Alpha_2::cases();
$cases = LanguageAlpha2::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
static::assertNotNull($case->toISO639_Name());
static::assertNotNull($case->toLanguageName());
}
}

Expand All @@ -52,6 +52,6 @@ public function testAllCasesCanBeConvertedToISO392_Name(): void
*/
public function testUpperCaseValue(): void
{
static::assertSame('AB', ISO639_1_Alpha_2::Abkhazian->upperCaseValue());
static::assertSame('AB', LanguageAlpha2::Abkhazian->upperCaseValue());
}
}
24 changes: 12 additions & 12 deletions tests/Unit/Language/ISO639_2_Alpha_3BibliographicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@
namespace PrinsFrank\Standards\Tests\Unit\Language;

use PHPUnit\Framework\TestCase;
use PrinsFrank\Standards\Language\ISO639_2_Alpha_3_Bibliographic;
use PrinsFrank\Standards\Language\LanguageAlpha3Bibliographic;

/**
* @coversDefaultClass \PrinsFrank\Standards\Language\ISO639_2_Alpha_3_Bibliographic
* @coversDefaultClass \PrinsFrank\Standards\Language\LanguageAlpha3Bibliographic
*/
class ISO639_2_Alpha_3BibliographicTest extends TestCase
{
/**
* @covers ::toISO639_1_Alpha_2
* @covers ::toLanguageAlpha2
*/
public function testAllCasesCanBeConvertedToISO639_1(): void
{
$cases = ISO639_2_Alpha_3_Bibliographic::cases();
$cases = LanguageAlpha3Bibliographic::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
static::assertNotNull($case->toISO639_1_Alpha_2());
static::assertNotNull($case->toLanguageAlpha2());
}
}

/**
* @covers ::toISO639_2_Alpha_3_Terminology
* @covers ::toLanguageAlpha3Terminology
*/
public function testAllCasesCanBeConvertedToISO639_2_Terminology(): void
{
$cases = ISO639_2_Alpha_3_Bibliographic::cases();
$cases = LanguageAlpha3Bibliographic::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
static::assertNotNull($case->toISO639_2_Alpha_3_Terminology());
static::assertNotNull($case->toLanguageAlpha3Terminology());
}
}

/**
* @covers ::toISO639_Name
* @covers ::toLanguageName
*/
public function testAllCasesCanBeConvertedToISO639_Name(): void
{
$cases = ISO639_2_Alpha_3_Bibliographic::cases();
$cases = LanguageAlpha3Bibliographic::cases();
static::assertNotEmpty($cases);
foreach ($cases as $case) {
static::assertNotNull($case->toISO639_Name());
static::assertNotNull($case->toLanguageName());
}
}

Expand All @@ -52,6 +52,6 @@ public function testAllCasesCanBeConvertedToISO639_Name(): void
*/
public function testUpperCaseValue(): void
{
static::assertSame('ALB', ISO639_2_Alpha_3_Bibliographic::Albanian->upperCaseValue());
static::assertSame('ALB', LanguageAlpha3Bibliographic::Albanian->upperCaseValue());
}
}
Loading

0 comments on commit a305356

Please sign in to comment.