Skip to content

Commit

Permalink
Add intl-version to matrix
Browse files Browse the repository at this point in the history
As it looks like some intl-versions are bolloks....
  • Loading branch information
heiglandreas committed Aug 5, 2023
1 parent 1be4417 commit d034339
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@ jobs:
matrix:
# operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2']
icu-versions: ['73.1', '71.1', '69.1', '67.1']
experimental: [false]
include:
- php-versions: '8.3'
experimental: true
name: PHP ${{ matrix.php-versions }} # Test on ${{ matrix.operating-system }}
name: PHP ${{ matrix.php-versions }}-icu${{ matrix.icu-versions }} # Test on ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: sodium
extensions: sodium, intl-${{matrix.icu-version}}
ini-values: post_max_size=256M, short_open_tag=On
coverage: xdebug
- name: prepare
Expand Down
6 changes: 6 additions & 0 deletions intlTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
/**
* Copyright Andreas Heigl <[email protected]>
*
* Licensed under the MIT-license. For details see the included file LICENSE.md
*/
16 changes: 9 additions & 7 deletions src/CalendarDayFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,26 @@

use IntlCalendar;
use Org_Heigl\Holidaychecker\Exceptions\UnknownCalendar;
use UnexpectedValueException;
use function sprintf;

class CalendarDayFactory
{
public static function createCalendarDay(int $day, int $month, string $calendar): CalendarDay
public static function createCalendarDay(int $day, int $month, string $calendar) : CalendarDay
{
if (!Calendar::isValidCalendarName($calendar)) {
throw new UnknownCalendar(sprintf(
'The calendar %s is not known to the ICU',
$calendar
));
}
$calendar = IntlCalendar::createInstance('UTC', '@calendar=' . $calendar);
if (null === $calendar) {
throw new UnexpectedValueException('Expected instance of IntlCalendar, got null');
}
$icuCalendar = IntlCalendar::createInstance('UTC', '@calendar=' . $calendar);

return new CalendarDay($day, $month, $calendar);
if ($icuCalendar === null) {
throw new UnknownCalendar(sprintf(
'The %s calendar could not be created',
$calendar
));
}
return new CalendarDay($day, $month, $icuCalendar);
}
}

0 comments on commit d034339

Please sign in to comment.