Skip to content

Commit

Permalink
Rename sources to reflect name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinsFrank committed Mar 22, 2023
1 parent f2a3537 commit 22e79e8
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace PrinsFrank\Standards\Dev\DataSource\Country;

use PrinsFrank\Standards\Country\ISO3166_1_Alpha_2;
use PrinsFrank\Standards\Country\CountryAlpha2;
use PrinsFrank\Standards\Dev\DataSource\HtmlDataSource;
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO3166_1_Alpha_2_Source implements HtmlDataSource
class CountryAlpha2Source implements HtmlDataSource
{
public static function url(): string
{
Expand Down Expand Up @@ -43,7 +43,7 @@ public static function transformValue(string $value): string|int|null

public static function getSpecFQN(): string
{
return ISO3166_1_Alpha_2::class;
return CountryAlpha2::class;
}

public static function getKeyEnumFQN(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace PrinsFrank\Standards\Dev\DataSource\Country;

use PrinsFrank\Standards\Country\ISO3166_1_Alpha_3;
use PrinsFrank\Standards\Country\CountryAlpha3;
use PrinsFrank\Standards\Dev\DataSource\HtmlDataSource;
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO3166_1_Alpha_3_Source implements HtmlDataSource
class CountryAlpha3Source implements HtmlDataSource
{
public static function url(): string
{
Expand Down Expand Up @@ -43,7 +43,7 @@ public static function transformValue(string $value): string|int|null

public static function getSpecFQN(): string
{
return ISO3166_1_Alpha_3::class;
return CountryAlpha3::class;
}

public static function getKeyEnumFQN(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace PrinsFrank\Standards\Dev\DataSource\Country;

use PrinsFrank\Standards\Country\ISO3166_1_Alpha_2;
use PrinsFrank\Standards\Country\ISO3166_1_Name;
use PrinsFrank\Standards\Country\CountryAlpha2;
use PrinsFrank\Standards\Country\CountryName;
use PrinsFrank\Standards\Dev\DataSource\HtmlDataSource;
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO3166_1_Name_Source implements HtmlDataSource
class CountryNameSource implements HtmlDataSource
{
public static function url(): string
{
Expand Down Expand Up @@ -44,12 +44,12 @@ public static function transformValue(string $value): string|int|null

public static function getSpecFQN(): string
{
return ISO3166_1_Name::class;
return CountryName::class;
}

public static function getKeyEnumFQN(): string
{
return ISO3166_1_Alpha_2::class;
return CountryAlpha2::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 @@
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO3166_1_Numeric_Source implements HtmlDataSource
class CountryNumericSource implements HtmlDataSource
{
public static function url(): string
{
Expand Down
15 changes: 0 additions & 15 deletions dev/DataSource/CountryShort/CountryAlpha2Source.php

This file was deleted.

15 changes: 0 additions & 15 deletions dev/DataSource/CountryShort/CountryAlpha3Source.php

This file was deleted.

15 changes: 0 additions & 15 deletions dev/DataSource/CountryShort/CountryNameSource.php

This file was deleted.

15 changes: 0 additions & 15 deletions dev/DataSource/CountryShort/CountryNumericSource.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO4217_Alpha_3_Source implements XmlDataSource
class CurrencyAlpha3Source implements XmlDataSource
{
public static function url(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO4217_Name_Source implements XmlDataSource
class CurrencyNameSource implements XmlDataSource
{
public static function url(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO4217_Numeric_Source implements XmlDataSource
class CurrencyNumericSource implements XmlDataSource
{
public static function url(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO639_1_Alpha_2_Source implements HtmlDataSource
class LanguageAlpha2Source implements HtmlDataSource
{
public static function url(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO639_2_Alpha_3_Bibliographic_Source implements HtmlDataSource
class LanguageAlpha3BibliographicSource implements HtmlDataSource
{
public static function url(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO639_2_Alpha_3_Common_Source implements HtmlDataSource
class LanguageAlpha3CommonSource implements HtmlDataSource
{
public static function url(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO639_2_Alpha_3_Terminology_Source implements HtmlDataSource
class LanguageAlpha3TerminologySource implements HtmlDataSource
{
public static function url(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Symfony\Component\Panther\Client;
use Symfony\Component\Panther\DomCrawler\Crawler;

class ISO639_Name_Source implements HtmlDataSource
class LanguageNameSource implements HtmlDataSource
{
public static function url(): string
{
Expand Down
1 change: 0 additions & 1 deletion dev/DataSource/SpecType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
enum SpecType
{
case COUNTRY;
case COUNTRY_SHORT;
case CURRENCY;
case HTTP_STATUS_CODES;
case HTTP_METHODS;
Expand Down
53 changes: 20 additions & 33 deletions dev/SpecUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@

use Composer\Script\Event;
use InvalidArgumentException;
use PrinsFrank\Standards\Dev\DataSource\Country\ISO3166_1_Alpha_2_Source;
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;
use PrinsFrank\Standards\Dev\DataSource\Country\CountryAlpha2Source;
use PrinsFrank\Standards\Dev\DataSource\Country\CountryAlpha3Source;
use PrinsFrank\Standards\Dev\DataSource\Country\CountryNameSource;
use PrinsFrank\Standards\Dev\DataSource\Country\CountryNumericSource;
use PrinsFrank\Standards\Dev\DataSource\Currency\CurrencyAlpha3Source;
use PrinsFrank\Standards\Dev\DataSource\Currency\CurrencyNameSource;
use PrinsFrank\Standards\Dev\DataSource\Currency\CurrencyNumericSource;
use PrinsFrank\Standards\Dev\DataSource\DataSource;
use PrinsFrank\Standards\Dev\DataSource\HtmlDataSource;
use PrinsFrank\Standards\Dev\DataSource\Http\HttpMethodSource;
use PrinsFrank\Standards\Dev\DataSource\Http\HttpStatusCodeSource;
use PrinsFrank\Standards\Dev\DataSource\Language\ISO639_1_Alpha_2_Source;
use PrinsFrank\Standards\Dev\DataSource\Language\ISO639_2_Alpha_3_Bibliographic_Source;
use PrinsFrank\Standards\Dev\DataSource\Language\ISO639_2_Alpha_3_Common_Source;
use PrinsFrank\Standards\Dev\DataSource\Language\ISO639_2_Alpha_3_Terminology_Source;
use PrinsFrank\Standards\Dev\DataSource\Language\ISO639_Name_Source;
use PrinsFrank\Standards\Dev\DataSource\Language\LanguageAlpha2Source;
use PrinsFrank\Standards\Dev\DataSource\Language\LanguageAlpha3BibliographicSource;
use PrinsFrank\Standards\Dev\DataSource\Language\LanguageAlpha3CommonSource;
use PrinsFrank\Standards\Dev\DataSource\Language\LanguageAlpha3TerminologySource;
use PrinsFrank\Standards\Dev\DataSource\Language\LanguageNameSource;
use PrinsFrank\Standards\Dev\DataSource\SpecType;
use PrinsFrank\Standards\Dev\DataSource\XmlDataSource;
use PrinsFrank\Standards\Dev\DataSourceExtractor\HtmlDataSourceExtractor;
Expand All @@ -39,14 +35,6 @@ class SpecUpdater
{
/** @var array<class-string<DataSource>> */
public const COUNTRY_SOURCES = [
ISO3166_1_Numeric_Source::class,
ISO3166_1_Alpha_2_Source::class,
ISO3166_1_Alpha_3_Source::class,
ISO3166_1_Name_Source::class,
];

/** @var array<class-string<DataSource>> */
public const COUNTRY_SHORT_SOURCES = [
CountryNumericSource::class,
CountryAlpha2Source::class,
CountryAlpha3Source::class,
Expand All @@ -55,9 +43,9 @@ class SpecUpdater

/** @var array<class-string<DataSource>> */
public const CURRENCY_SOURCES = [
ISO4217_Alpha_3_Source::class,
ISO4217_Numeric_Source::class,
ISO4217_Name_Source::class,
CurrencyAlpha3Source::class,
CurrencyNumericSource::class,
CurrencyNameSource::class,
];

/** @var array<class-string<DataSource>> */
Expand All @@ -72,11 +60,11 @@ class SpecUpdater

/** @var array<class-string<DataSource>> */
public const LANGUAGE_SOURCES = [
ISO639_1_Alpha_2_Source::class,
ISO639_2_Alpha_3_Bibliographic_Source::class,
ISO639_2_Alpha_3_Terminology_Source::class,
ISO639_2_Alpha_3_Common_Source::class,
ISO639_Name_Source::class,
LanguageAlpha2Source::class,
LanguageAlpha3BibliographicSource::class,
LanguageAlpha3TerminologySource::class,
LanguageAlpha3CommonSource::class,
LanguageNameSource::class,
];

private const MAX_TRIES = 5;
Expand All @@ -91,7 +79,6 @@ 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 22e79e8

Please sign in to comment.