diff --git a/.github/workflows/update-spec-http.yml b/.github/workflows/update-spec-http-methods.yml similarity index 84% rename from .github/workflows/update-spec-http.yml rename to .github/workflows/update-spec-http-methods.yml index b3f892a5..d177a506 100644 --- a/.github/workflows/update-spec-http.yml +++ b/.github/workflows/update-spec-http-methods.yml @@ -1,4 +1,4 @@ -name: Daily HTTP spec update +name: Daily HTTP Method spec update on: workflow_dispatch: @@ -14,7 +14,7 @@ jobs: - name: Install dependencies run: composer install - name: Run standard update command - run: composer update-spec -- --type=http + run: composer update-spec -- --type=http-methods - name: Run CSFixer run: composer cs:fix - name: Create Pull Request @@ -23,7 +23,7 @@ jobs: with: commit-message: Automatic spec update from upstream changes delete-branch: true - title: 'Automatic Http spec update' + title: 'Automatic Http method spec update' body: | This PR makes sure the content of this package is updated with upstream changes in the specs. labels: | diff --git a/.github/workflows/update-spec-http-status-codes.yml b/.github/workflows/update-spec-http-status-codes.yml new file mode 100644 index 00000000..a713e6dd --- /dev/null +++ b/.github/workflows/update-spec-http-status-codes.yml @@ -0,0 +1,32 @@ +name: Daily HTTP status code spec update + +on: + workflow_dispatch: + schedule: + - cron: '55 17 * * *' + +jobs: + update-specs: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Install dependencies + run: composer install + - name: Run standard update command + run: composer update-spec -- --type=http-status-codes + - name: Run CSFixer + run: composer cs:fix + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v4 + with: + commit-message: Automatic spec update from upstream changes + delete-branch: true + title: 'Automatic Http status code spec update' + body: | + This PR makes sure the content of this package is updated with upstream changes in the specs. + labels: | + spec-update + automated pr + reviewers: prinsfrank diff --git a/dev/DataSource/SpecType.php b/dev/DataSource/SpecType.php index 3e2241c1..30428dfa 100644 --- a/dev/DataSource/SpecType.php +++ b/dev/DataSource/SpecType.php @@ -7,6 +7,7 @@ enum SpecType { case COUNTRY; case CURRENCY; - case HTTP; + case HTTP_STATUS_CODES; + case HTTP_METHODS; case LANGUAGE; } diff --git a/dev/SpecUpdater.php b/dev/SpecUpdater.php index 70bf2bfd..bcc33aa5 100644 --- a/dev/SpecUpdater.php +++ b/dev/SpecUpdater.php @@ -49,8 +49,12 @@ class SpecUpdater ]; /** @var array> */ - public const HTTP_SOURCES = [ + public const HTTP_STATUS_CODE_SOURCES = [ HttpStatusCodeSource::class, + ]; + + /** @var array> */ + public const HTTP_METHOD_SOURCES = [ HttpMethodSource::class, ]; @@ -73,12 +77,13 @@ public static function update(Event $event): void $type = $event->getArguments()[0] ?? throw new InvalidArgumentException('Please specify the type with "-- --type=' . implode(',', UnitEnum::names(SpecType::class)) . '"'); $type = str_starts_with($type, '--type=') === false ? throw new InvalidArgumentException('Please specify the type with "-- --type=' . implode(',', UnitEnum::names(SpecType::class)) . '"') : substr($type, 7); - $sources = match (UnitEnum::tryFromKey(SpecType::class, strtoupper($type))) { - SpecType::COUNTRY => self::COUNTRY_SOURCES, - SpecType::CURRENCY => self::CURRENCY_SOURCES, - SpecType::HTTP => self::HTTP_SOURCES, - SpecType::LANGUAGE => self::LANGUAGE_SOURCES, - default => throw new InvalidArgumentException('Automatic spec updating for type "' . $type . '" not implemented'), + $sources = match (UnitEnum::tryFromKey(SpecType::class, strtoupper(str_replace('-', '_', $type)))) { + SpecType::COUNTRY => self::COUNTRY_SOURCES, + SpecType::CURRENCY => self::CURRENCY_SOURCES, + SpecType::HTTP_STATUS_CODES => self::HTTP_STATUS_CODE_SOURCES, + SpecType::HTTP_METHODS => self::HTTP_METHOD_SOURCES, + SpecType::LANGUAGE => self::LANGUAGE_SOURCES, + default => throw new InvalidArgumentException('Automatic spec updating for type "' . $type . '" not implemented'), }; /** @var class-string $sourceFQN */