diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 91d0df704..206439d0d 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -1,9 +1,11 @@ */ -$finder = PhpCsFixer\Finder::create()->in(__DIR__); -$config = new PhpCsFixer\Config(); -$config->setRiskyAllowed(true)->setRules([ - '@PER' => true, - '@Symfony' => true, - 'combine_consecutive_issets' => true, - 'combine_consecutive_unsets' => true, - 'explicit_string_variable' => true, - 'no_superfluous_elseif' => true, - 'no_superfluous_phpdoc_tags' => ['remove_inheritdoc' => true], - 'not_operator_with_successor_space' => true, - 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true ], - 'ordered_class_elements' => true, +$config = new AzuyaLabs\PhpCsFixerConfig\Config('2015', null, 'Yasumi'); +$config->getFinder()->in(__DIR__)->notPath('var'); + +$defaults = $config->getRules(); - // Risky - 'declare_strict_types' => true, - 'dir_constant' => true, - 'get_class_to_class_keyword' => true, - 'is_null' => true, - 'modernize_strpos' => true, - 'modernize_types_casting' => true, - 'self_accessor' => true, -])->setFinder($finder); +$config->setRules(array_merge($defaults, [ + 'php_unit_method_casing' => ['case' => 'camel_case'], +])); return $config; diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ef0d6d12..6c5fbe8f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,8 +14,15 @@ changes. ### Changed +- Holiday calculation methods in providers are now protected instead of private + to allow use in [custom providers](https://www.yasumi.dev/docs/cookbook/custom_provider/). + [\#331](https://github.com/azuyalabs/yasumi/issues/331) + ### Fixed +- Handle invalid/changed timezones Australia/ACT and Europe/Kiev [\#343](https://github.com/azuyalabs/yasumi/pull/343) + ([Kevin Papst](https://github.com/kevinpapst)) + ### Removed ## [2.7.0] - 2024-01-02 diff --git a/composer.json b/composer.json index ca2d3ebea..8db19a93d 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "azuyalabs/yasumi", - "description": "The easy PHP Library for calculating holidays.", + "description": "The easy PHP Library for calculating holidays", "license": "MIT", "type": "library", "keywords": [ @@ -40,12 +40,12 @@ }, "require-dev": { "ext-intl": "*", - "friendsofphp/php-cs-fixer": "^2.19 || ^3.40", + "azuyalabs/php-cs-fixer-config": "^0.3", "mikey179/vfsstream": "^1.6", "phan/phan": "^5.4", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^8.5 || ^9.6", - "vimeo/psalm": "^5.16" + "vimeo/psalm": "^5.20" }, "suggest": { "ext-calendar": "For calculating the date of Easter" @@ -72,7 +72,8 @@ "@phpstan", "@psalm" ], - "format": "./vendor/bin/php-cs-fixer fix", + "cs": "vendor/bin/php-cs-fixer fix -v --diff --dry-run", + "cs-fix": "vendor/bin/php-cs-fixer fix -v", "phan": "vendor/bin/phan -C", "phpstan": "vendor/bin/phpstan analyse", "psalm": "vendor/bin/psalm --threads=2", diff --git a/examples/basic.php b/examples/basic.php index 4407f7351..9cf5b8f98 100644 --- a/examples/basic.php +++ b/examples/basic.php @@ -2,7 +2,20 @@ // This file demonstrates the general use of Yasumi and its basic methods. -declare(strict_types=1); +declare(strict_types = 1); + +/** + * This file is part of the 'Yasumi' package. + * + * The easy PHP Library for calculating holidays. + * + * Copyright (c) 2015 - 2024 AzuyaLabs + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * @author Sacha Telgenhof + */ require 'vendor/autoload.php'; @@ -10,20 +23,20 @@ $holidays = Yasumi\Yasumi::create('USA', (int) date('Y')); // Show the number of defined holidays -echo 'Number of defined holidays: '.$holidays->count().PHP_EOL; +echo 'Number of defined holidays: ' . $holidays->count() . PHP_EOL; echo PHP_EOL; // Display a list all of the holiday names (short names) -echo 'List of all the holiday names: '.PHP_EOL; +echo 'List of all the holiday names: ' . PHP_EOL; foreach ($holidays->getHolidayNames() as $name) { - echo $name.PHP_EOL; + echo $name . PHP_EOL; } echo PHP_EOL; // Display a list all of the holiday dates -echo 'List of all the holiday dates:'.PHP_EOL; +echo 'List of all the holiday dates:' . PHP_EOL; foreach ($holidays->getHolidayDates() as $date) { - echo $date.PHP_EOL; + echo $date . PHP_EOL; } echo PHP_EOL; @@ -31,17 +44,17 @@ $independenceDay = $holidays->getHoliday('independenceDay'); // Show the localized name -echo 'Name of the holiday : '.$independenceDay->getName().PHP_EOL; +echo 'Name of the holiday : ' . $independenceDay->getName() . PHP_EOL; // Show the date -echo 'Date of the holiday : '.$independenceDay.PHP_EOL; +echo 'Date of the holiday : ' . $independenceDay . PHP_EOL; // Show the type of holiday -echo 'Type of holiday : '.$independenceDay->getType().PHP_EOL; +echo 'Type of holiday : ' . $independenceDay->getType() . PHP_EOL; echo PHP_EOL; // Dump the holiday as a JSON object -echo 'Holiday as a JSON object:'.PHP_EOL; +echo 'Holiday as a JSON object:' . PHP_EOL; echo json_encode($independenceDay, JSON_PRETTY_PRINT); echo PHP_EOL; diff --git a/examples/between_filter.php b/examples/between_filter.php index 4b1358c9a..4b8b46f7c 100644 --- a/examples/between_filter.php +++ b/examples/between_filter.php @@ -3,7 +3,20 @@ // This file demonstrates the use of the `between` filter, selecting only a number of holidays // that fall in the given date range. -declare(strict_types=1); +declare(strict_types = 1); + +/** + * This file is part of the 'Yasumi' package. + * + * The easy PHP Library for calculating holidays. + * + * Copyright (c) 2015 - 2024 AzuyaLabs + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * @author Sacha Telgenhof + */ require 'vendor/autoload.php'; @@ -12,16 +25,16 @@ // Use the factory to create a new holiday provider instance $holidays = Yasumi\Yasumi::create('Italy', $year); $holidaysInDecember = $holidays->between( - new DateTime('12/01/'.$year), - new DateTime('12/31/'.$year) + new DateTime('12/01/' . $year), + new DateTime('12/31/' . $year) ); // Show all holidays in Italy for December -echo 'List of all the holidays in December: '.PHP_EOL; +echo 'List of all the holidays in December: ' . PHP_EOL; foreach ($holidaysInDecember as $holiday) { - echo $holiday.' - '.$holiday->getName().PHP_EOL; + echo $holiday . ' - ' . $holiday->getName() . PHP_EOL; } echo PHP_EOL; // Show the number of filtered holidays -echo 'Number of filtered holidays: '.$holidaysInDecember->count().PHP_EOL; +echo 'Number of filtered holidays: ' . $holidaysInDecember->count() . PHP_EOL; diff --git a/examples/custom_provider.php b/examples/custom_provider.php index 773f93cc3..57f514d63 100644 --- a/examples/custom_provider.php +++ b/examples/custom_provider.php @@ -4,7 +4,20 @@ // those scenarios where you would need only a subset of holidays of an existing provider. Or, if you you like to // extend an existing provider with additional, non-standard holidays. -declare(strict_types=1); +declare(strict_types = 1); + +/** + * This file is part of the 'Yasumi' package. + * + * The easy PHP Library for calculating holidays. + * + * Copyright (c) 2015 - 2024 AzuyaLabs + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * @author Sacha Telgenhof + */ require 'vendor/autoload.php'; @@ -33,11 +46,11 @@ public function initialize(): void $NYSEHolidays = Yasumi\Yasumi::create(NYSE::class, (int) date('Y')); // We then can retrieve the NYSE observed holidays in the usual manner: -echo 'List of all the holiday names: '.PHP_EOL; +echo 'List of all the holiday names: ' . PHP_EOL; foreach ($NYSEHolidays->getHolidayNames() as $day) { - echo $day.PHP_EOL; + echo $day . PHP_EOL; } echo PHP_EOL; // Use the count() method to show how many holidays are returned -echo 'Number of defined holidays: '.$NYSEHolidays->count().PHP_EOL; +echo 'Number of defined holidays: ' . $NYSEHolidays->count() . PHP_EOL; diff --git a/examples/filters.php b/examples/filters.php index 3a82af460..5e85543ab 100644 --- a/examples/filters.php +++ b/examples/filters.php @@ -4,7 +4,20 @@ // based on certain conditions. In this examples we show only the holidays that are // marked as 'official'. -declare(strict_types=1); +declare(strict_types = 1); + +/** + * This file is part of the 'Yasumi' package. + * + * The easy PHP Library for calculating holidays. + * + * Copyright (c) 2015 - 2024 AzuyaLabs + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * @author Sacha Telgenhof + */ require 'vendor/autoload.php'; @@ -14,7 +27,7 @@ // Create a filter instance for the official holidays $official = new Yasumi\Filters\OfficialHolidaysFilter($holidays->getIterator()); -echo 'List of all official holidays: '.PHP_EOL; +echo 'List of all official holidays: ' . PHP_EOL; foreach ($official as $day) { - echo $day->getName().PHP_EOL; + echo $day->getName() . PHP_EOL; } diff --git a/phpinsights.php b/phpinsights.php index 4b5520d8b..9dbda25a8 100644 --- a/phpinsights.php +++ b/phpinsights.php @@ -1,6 +1,19 @@ + */ return [ /* diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fcf8aea40..62403f3bd 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -18,6 +18,10 @@ verbose="true" > + + + + ./src/Yasumi diff --git a/rector.php b/rector.php index a75a58ab8..112903d93 100644 --- a/rector.php +++ b/rector.php @@ -1,6 +1,19 @@ + */ use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; @@ -8,8 +21,8 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->paths([ - __DIR__.'/src', - __DIR__.'/tests', + __DIR__ . '/src', + __DIR__ . '/tests', ]); // single rules diff --git a/src/Yasumi/Exception/Exception.php b/src/Yasumi/Exception/Exception.php index fe9254e73..4faee05ea 100644 --- a/src/Yasumi/Exception/Exception.php +++ b/src/Yasumi/Exception/Exception.php @@ -1,9 +1,11 @@ year >= 1700) { $easter = $this->calculateEaster($this->year, $this->timezone); @@ -138,7 +140,7 @@ private function addCarnvalHolidays(): void * * @link https://en.wikipedia.org/wiki/Day_of_Remembrance_for_Truth_and_Justice */ - private function addRemembranceDay(): void + protected function addRemembranceDay(): void { if ($this->year >= 2006) { $this->addHoliday(new Holiday( @@ -164,7 +166,7 @@ private function addRemembranceDay(): void * * @link https://en.wikipedia.org/wiki/Malvinas_Day */ - private function addMalvinasDay(): void + protected function addMalvinasDay(): void { if ($this->year >= 1982) { $this->addHoliday(new Holiday( @@ -192,7 +194,7 @@ private function addMalvinasDay(): void * * @link https://en.wikipedia.org/wiki/First_National_Government */ - private function addMayRevolution(): void + protected function addMayRevolution(): void { if ($this->year >= 1810) { $this->addHoliday(new Holiday( @@ -213,7 +215,7 @@ private function addMayRevolution(): void * Anniversary of the death of Martín Miguel de Güemes, general of the * Argentine War of Independence. */ - private function addGeneralMartinMigueldeGuemesDay(): void + protected function addGeneralMartinMigueldeGuemesDay(): void { if ($this->year >= 1821) { $this->addHoliday(new Holiday( @@ -236,7 +238,7 @@ private function addGeneralMartinMigueldeGuemesDay(): void * * @link https://en.wikipedia.org/wiki/Flag_Day_(Argentina) */ - private function addFlagDay(): void + protected function addFlagDay(): void { if ($this->year >= 1938) { $this->addHoliday(new Holiday( @@ -258,7 +260,7 @@ private function addFlagDay(): void * * @link https://en.wikipedia.org/wiki/Argentine_Declaration_of_Independence */ - private function addIndependenceDay(): void + protected function addIndependenceDay(): void { if ($this->year >= self::PROCLAMATION_OF_INDEPENDENCE_YEAR) { $this->addHoliday(new Holiday( @@ -279,7 +281,7 @@ private function addIndependenceDay(): void * Anniversary of the death of José de San Martín, liberator of * Argentina, Chile and Peru. */ - private function addGeneralJoseSanMartinDay(): void + protected function addGeneralJoseSanMartinDay(): void { if ($this->year >= 1850) { $this->addHoliday(new Holiday( @@ -302,7 +304,7 @@ private function addGeneralJoseSanMartinDay(): void * * @link https://en.wikipedia.org/wiki/Columbus_Day */ - private function addRaceDay(): void + protected function addRaceDay(): void { if ($this->year >= 1492) { $this->addHoliday(new Holiday( @@ -325,7 +327,7 @@ private function addRaceDay(): void * * @link https://en.wikipedia.org/wiki/National_Sovereignty_Day */ - private function addNationalSovereigntyDay(): void + protected function addNationalSovereigntyDay(): void { if ($this->year >= 2010) { $this->addHoliday(new Holiday( @@ -348,7 +350,7 @@ private function addNationalSovereigntyDay(): void * * @link https://en.wikipedia.org/wiki/Immaculate_Conception */ - private function addImmaculateConceptionDay(): void + protected function addImmaculateConceptionDay(): void { if ($this->year >= 1900) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Australia.php b/src/Yasumi/Provider/Australia.php index 16e559123..f92d49fc6 100644 --- a/src/Yasumi/Provider/Australia.php +++ b/src/Yasumi/Provider/Australia.php @@ -1,9 +1,11 @@ year}-01-01", DateTimeZoneFactory::getDateTimeZone($this->timezone)); $this->addHoliday(new Holiday( @@ -129,7 +131,7 @@ private function calculateNewYearHolidays(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateAustraliaDay(): void + protected function calculateAustraliaDay(): void { $date = new \DateTime("{$this->year}-01-26", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -172,7 +174,7 @@ private function calculateAustraliaDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateAnzacDay(): void + protected function calculateAnzacDay(): void { if ($this->year < 1921) { return; @@ -217,7 +219,7 @@ private function calculateAnzacDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateNationalDayOfMourning(): void + protected function calculateNationalDayOfMourning(): void { if (2022 !== $this->year) { return; @@ -244,7 +246,7 @@ private function calculateNationalDayOfMourning(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateChristmasDay(): void + protected function calculateChristmasDay(): void { $christmasDay = new \DateTime("{$this->year}-12-25", DateTimeZoneFactory::getDateTimeZone($this->timezone)); $boxingDay = new \DateTime("{$this->year}-12-26", DateTimeZoneFactory::getDateTimeZone($this->timezone)); diff --git a/src/Yasumi/Provider/Australia/AustralianCapitalTerritory.php b/src/Yasumi/Provider/Australia/AustralianCapitalTerritory.php index 819cb723e..c34251b83 100644 --- a/src/Yasumi/Provider/Australia/AustralianCapitalTerritory.php +++ b/src/Yasumi/Provider/Australia/AustralianCapitalTerritory.php @@ -1,9 +1,11 @@ timezone = 'Australia/Sydney'; + } catch (\Exception $e) { // @phpstan-ignore-line + // DateInvalidTimeZoneException since 8.3 + $this->timezone = 'Australia/ACT'; + } + parent::initialize(); $this->addHoliday($this->easterSunday($this->year, $this->timezone, $this->locale)); @@ -69,7 +79,7 @@ public function initialize(): void * * @throws \Exception */ - private function easterSunday( + protected function easterSunday( int $year, string $timezone, string $locale, @@ -101,7 +111,7 @@ private function easterSunday( * * @throws \Exception */ - private function easterSaturday( + protected function easterSaturday( int $year, string $timezone, string $locale, @@ -137,12 +147,12 @@ private function easterSaturday( * @throws \InvalidArgumentException * @throws \Exception */ - private function calculateQueensBirthday(): void + protected function calculateQueensBirthday(): void { $this->addHoliday(new Holiday( 'queensBirthday', [], - new \DateTime('second monday of june '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('second monday of june ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); @@ -153,7 +163,7 @@ private function calculateQueensBirthday(): void * * @throws \Exception */ - private function calculateLabourDay(): void + protected function calculateLabourDay(): void { $date = new \DateTime("first monday of october {$this->year}", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -165,7 +175,7 @@ private function calculateLabourDay(): void * * @throws \Exception */ - private function calculateCanberraDay(): void + protected function calculateCanberraDay(): void { $datePattern = $this->year < 2007 ? "third monday of march {$this->year}" : "second monday of march {$this->year}"; @@ -184,16 +194,16 @@ private function calculateCanberraDay(): void * * @throws \Exception */ - private function calculateReconciliationDay(): void + protected function calculateReconciliationDay(): void { if ($this->year < 2018) { return; } - $date = new \DateTime($this->year.'-05-27', DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime($this->year . '-05-27', DateTimeZoneFactory::getDateTimeZone($this->timezone)); $day = (int) $date->format('w'); if (1 !== $day) { - $date = $date->add(0 === $day ? new \DateInterval('P1D') : new \DateInterval('P'.(8 - $day).'D')); + $date = $date->add(0 === $day ? new \DateInterval('P1D') : new \DateInterval('P' . (8 - $day) . 'D')); } $this->addHoliday(new Holiday('reconciliationDay', ['en' => 'Reconciliation Day'], $date, $this->locale)); } diff --git a/src/Yasumi/Provider/Australia/NewSouthWales.php b/src/Yasumi/Provider/Australia/NewSouthWales.php index af4c71a6d..eb72ded0a 100644 --- a/src/Yasumi/Provider/Australia/NewSouthWales.php +++ b/src/Yasumi/Provider/Australia/NewSouthWales.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'queensBirthday', [], - new \DateTime('second monday of june '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('second monday of june ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); @@ -120,7 +122,7 @@ private function calculateQueensBirthday(): void * * @throws \Exception */ - private function calculateLabourDay(): void + protected function calculateLabourDay(): void { $date = new \DateTime("first monday of october {$this->year}", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -133,12 +135,12 @@ private function calculateLabourDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function calculateBankHoliday(): void + protected function calculateBankHoliday(): void { $this->addHoliday(new Holiday( 'bankHoliday', ['en' => 'Bank Holiday'], - new \DateTime('first monday of august '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('first monday of august ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_BANK )); diff --git a/src/Yasumi/Provider/Australia/NorthernTerritory.php b/src/Yasumi/Provider/Australia/NorthernTerritory.php index be4ca50eb..b9c88d4c0 100644 --- a/src/Yasumi/Provider/Australia/NorthernTerritory.php +++ b/src/Yasumi/Provider/Australia/NorthernTerritory.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'queensBirthday', [], - new \DateTime('second monday of june '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('second monday of june ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); @@ -119,7 +121,7 @@ private function calculateQueensBirthday(): void * * @throws \Exception */ - private function calculateMayDay(): void + protected function calculateMayDay(): void { $date = new \DateTime("first monday of may {$this->year}", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -134,12 +136,12 @@ private function calculateMayDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function calculatePicnicDay(): void + protected function calculatePicnicDay(): void { $this->addHoliday(new Holiday( 'picnicDay', ['en' => 'Picnic Day'], - new \DateTime('first monday of august '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('first monday of august ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); diff --git a/src/Yasumi/Provider/Australia/Queensland.php b/src/Yasumi/Provider/Australia/Queensland.php index 8299eb353..6becbfd38 100644 --- a/src/Yasumi/Provider/Australia/Queensland.php +++ b/src/Yasumi/Provider/Australia/Queensland.php @@ -1,9 +1,11 @@ year; + $birthDay = 'first monday of october ' . $this->year; if ($this->year < 2012 || 2013 === $this->year || 2014 === $this->year || 2015 === $this->year) { - $birthDay = 'second monday of june '.$this->year; + $birthDay = 'second monday of june ' . $this->year; } $this->addHoliday(new Holiday( @@ -85,7 +87,7 @@ private function calculateQueensBirthday(): void * * @throws \Exception */ - private function calculateLabourDay(): void + protected function calculateLabourDay(): void { $date = new \DateTime("first monday of may {$this->year}", DateTimeZoneFactory::getDateTimeZone($this->timezone)); if (2013 === $this->year || 2014 === $this->year || 2015 === $this->year) { diff --git a/src/Yasumi/Provider/Australia/Queensland/Brisbane.php b/src/Yasumi/Provider/Australia/Queensland/Brisbane.php index 538402938..96c6c66be 100644 --- a/src/Yasumi/Provider/Australia/Queensland/Brisbane.php +++ b/src/Yasumi/Provider/Australia/Queensland/Brisbane.php @@ -1,9 +1,11 @@ year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime('first friday of august ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); if ($date->format('d') < 5) { $date = $date->add(new \DateInterval('P7D')); } diff --git a/src/Yasumi/Provider/Australia/SouthAustralia.php b/src/Yasumi/Provider/Australia/SouthAustralia.php index 75048026b..d27e69f33 100644 --- a/src/Yasumi/Provider/Australia/SouthAustralia.php +++ b/src/Yasumi/Provider/Australia/SouthAustralia.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'queensBirthday', [], - new \DateTime('second monday of june '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('second monday of june ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); @@ -127,7 +129,7 @@ private function calculateQueensBirthday(): void * * @throws \Exception */ - private function calculateLabourDay(): void + protected function calculateLabourDay(): void { $date = new \DateTime("first monday of october {$this->year}", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -142,13 +144,13 @@ private function calculateLabourDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function calculateAdelaideCupDay(): void + protected function calculateAdelaideCupDay(): void { if ($this->year >= 1973) { - $cupDay = 'second monday of march '.$this->year; + $cupDay = 'second monday of march ' . $this->year; if ($this->year < 2006) { - $cupDay = 'third monday of may '.$this->year; + $cupDay = 'third monday of may ' . $this->year; } $this->addHoliday(new Holiday( @@ -166,7 +168,7 @@ private function calculateAdelaideCupDay(): void * * @throws \Exception */ - private function calculateProclamationDay(): void + protected function calculateProclamationDay(): void { $christmasDay = new \DateTime("{$this->year}-12-25", DateTimeZoneFactory::getDateTimeZone($this->timezone)); diff --git a/src/Yasumi/Provider/Australia/Tasmania.php b/src/Yasumi/Provider/Australia/Tasmania.php index 5ccb1900e..9dce59344 100644 --- a/src/Yasumi/Provider/Australia/Tasmania.php +++ b/src/Yasumi/Provider/Australia/Tasmania.php @@ -1,9 +1,11 @@ year}", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -76,12 +78,12 @@ private function calculateEightHoursDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function calculateQueensBirthday(): void + protected function calculateQueensBirthday(): void { $this->addHoliday(new Holiday( 'queensBirthday', [], - new \DateTime('second monday of june '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('second monday of june ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); @@ -95,12 +97,12 @@ private function calculateQueensBirthday(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function calculateRecreationDay(): void + protected function calculateRecreationDay(): void { $this->addHoliday(new Holiday( 'recreationDay', ['en' => 'Recreation Day'], - new \DateTime('first monday of november '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('first monday of november ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); diff --git a/src/Yasumi/Provider/Australia/Tasmania/CentralNorth.php b/src/Yasumi/Provider/Australia/Tasmania/CentralNorth.php index aaa45dcf4..5134add2f 100644 --- a/src/Yasumi/Provider/Australia/Tasmania/CentralNorth.php +++ b/src/Yasumi/Provider/Australia/Tasmania/CentralNorth.php @@ -1,9 +1,11 @@ year.'-12-02', DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime($this->year . '-12-02', DateTimeZoneFactory::getDateTimeZone($this->timezone)); $date = $date->modify('previous friday'); if (! $date instanceof \DateTime) { diff --git a/src/Yasumi/Provider/Australia/Tasmania/FlindersIsland.php b/src/Yasumi/Provider/Australia/Tasmania/FlindersIsland.php index b4ee4ff8c..91f9d227b 100644 --- a/src/Yasumi/Provider/Australia/Tasmania/FlindersIsland.php +++ b/src/Yasumi/Provider/Australia/Tasmania/FlindersIsland.php @@ -1,9 +1,11 @@ year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime('third saturday of october ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); $date = $date->sub(new \DateInterval('P1D')); $this->addHoliday(new Holiday('flindersIslandShow', ['en' => 'Flinders Island Show'], $date, $this->locale)); } diff --git a/src/Yasumi/Provider/Australia/Tasmania/KingIsland.php b/src/Yasumi/Provider/Australia/Tasmania/KingIsland.php index b0c454540..1916b3ce2 100644 --- a/src/Yasumi/Provider/Australia/Tasmania/KingIsland.php +++ b/src/Yasumi/Provider/Australia/Tasmania/KingIsland.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'kingIslandShow', ['en' => 'King Island Show'], - new \DateTime('first tuesday of march '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('first tuesday of march ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); diff --git a/src/Yasumi/Provider/Australia/Tasmania/Northeast.php b/src/Yasumi/Provider/Australia/Tasmania/Northeast.php index eceb3b804..46fcf2dce 100644 --- a/src/Yasumi/Provider/Australia/Tasmania/Northeast.php +++ b/src/Yasumi/Provider/Australia/Tasmania/Northeast.php @@ -1,9 +1,11 @@ year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime('second saturday of october ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); $date = $date->sub(new \DateInterval('P2D')); $this->addHoliday(new Holiday('launcestonShow', ['en' => 'Royal Launceston Show'], $date, $this->locale)); } diff --git a/src/Yasumi/Provider/Australia/Tasmania/Northwest.php b/src/Yasumi/Provider/Australia/Tasmania/Northwest.php index 80f3a372c..395204930 100644 --- a/src/Yasumi/Provider/Australia/Tasmania/Northwest.php +++ b/src/Yasumi/Provider/Australia/Tasmania/Northwest.php @@ -1,9 +1,11 @@ year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime('first saturday of october ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); $date = $date->sub(new \DateInterval('P1D')); $this->addHoliday(new Holiday('burnieShow', ['en' => 'Burnie Show'], $date, $this->locale)); } diff --git a/src/Yasumi/Provider/Australia/Tasmania/Northwest/CircularHead.php b/src/Yasumi/Provider/Australia/Tasmania/Northwest/CircularHead.php index 4c407c65b..e6da79a16 100644 --- a/src/Yasumi/Provider/Australia/Tasmania/Northwest/CircularHead.php +++ b/src/Yasumi/Provider/Australia/Tasmania/Northwest/CircularHead.php @@ -1,9 +1,11 @@ year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime('first thursday of may ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); $date = $date->add(new \DateInterval('P1D')); $this->addHoliday(new Holiday('agfest', ['en' => 'AGFEST'], $date, $this->locale)); } diff --git a/src/Yasumi/Provider/Australia/Tasmania/South.php b/src/Yasumi/Provider/Australia/Tasmania/South.php index c963147bd..ee54acd74 100644 --- a/src/Yasumi/Provider/Australia/Tasmania/South.php +++ b/src/Yasumi/Provider/Australia/Tasmania/South.php @@ -1,9 +1,11 @@ year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime('fourth saturday of october ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)); $date = $date->sub(new \DateInterval('P2D')); $this->addHoliday(new Holiday('hobartShow', ['en' => 'Royal Hobart Show'], $date, $this->locale)); } diff --git a/src/Yasumi/Provider/Australia/Tasmania/South/Southeast.php b/src/Yasumi/Provider/Australia/Tasmania/South/Southeast.php index 76d224620..08b73d70f 100644 --- a/src/Yasumi/Provider/Australia/Tasmania/South/Southeast.php +++ b/src/Yasumi/Provider/Australia/Tasmania/South/Southeast.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'hobartRegatta', ['en' => 'Royal Hobart Regatta'], - new \DateTime('second monday of february '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('second monday of february ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); diff --git a/src/Yasumi/Provider/Australia/Victoria.php b/src/Yasumi/Provider/Australia/Victoria.php index a6d6954e7..1757a0a85 100644 --- a/src/Yasumi/Provider/Australia/Victoria.php +++ b/src/Yasumi/Provider/Australia/Victoria.php @@ -1,9 +1,11 @@ year}", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -149,12 +151,12 @@ private function calculateLabourDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function calculateQueensBirthday(): void + protected function calculateQueensBirthday(): void { $this->addHoliday(new Holiday( 'queensBirthday', [], - new \DateTime('second monday of june '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('second monday of june ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); @@ -165,9 +167,9 @@ private function calculateQueensBirthday(): void * * @throws \Exception */ - private function calculateMelbourneCupDay(): void + protected function calculateMelbourneCupDay(): void { - $date = new \DateTime('first Tuesday of November'." {$this->year}", DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime('first Tuesday of November' . " {$this->year}", DateTimeZoneFactory::getDateTimeZone($this->timezone)); $this->addHoliday(new Holiday('melbourneCup', ['en' => 'Melbourne Cup'], $date, $this->locale)); } @@ -177,7 +179,7 @@ private function calculateMelbourneCupDay(): void * * @throws \Exception */ - private function calculateAFLGrandFinalDay(): void + protected function calculateAFLGrandFinalDay(): void { switch ($this->year) { case 2015: diff --git a/src/Yasumi/Provider/Australia/WesternAustralia.php b/src/Yasumi/Provider/Australia/WesternAustralia.php index 39f820f19..ffe2fd801 100644 --- a/src/Yasumi/Provider/Australia/WesternAustralia.php +++ b/src/Yasumi/Provider/Australia/WesternAustralia.php @@ -1,9 +1,11 @@ year; + $birthDay = 'last monday of september ' . $this->year; if (2011 === $this->year) { $birthDay = '2011-10-28'; } @@ -89,7 +91,7 @@ private function calculateQueensBirthday(): void * * @throws \Exception */ - private function calculateLabourDay(): void + protected function calculateLabourDay(): void { $date = new \DateTime("first monday of march {$this->year}", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -104,12 +106,12 @@ private function calculateLabourDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function calculateWesternAustraliaDay(): void + protected function calculateWesternAustraliaDay(): void { $this->addHoliday(new Holiday( 'westernAustraliaDay', ['en' => 'Western Australia Day'], - new \DateTime('first monday of june '.$this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime('first monday of june ' . $this->year, DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); diff --git a/src/Yasumi/Provider/Austria.php b/src/Yasumi/Provider/Austria.php index db259971f..37898e399 100644 --- a/src/Yasumi/Provider/Austria.php +++ b/src/Yasumi/Provider/Austria.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'stLeopoldsDay', [], - new \DateTime($this->year.'-11-15', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-11-15', new \DateTimeZone($this->timezone)), $this->locale )); } @@ -116,7 +118,7 @@ protected function calculateStLeopoldsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateNationalDay(): void + protected function calculateNationalDay(): void { if ($this->year < 1955) { return; @@ -125,7 +127,7 @@ private function calculateNationalDay(): void $this->addHoliday(new Holiday( 'nationalDay', ['de' => 'Nationalfeiertag'], - new \DateTime($this->year.'-10-26', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-10-26', new \DateTimeZone($this->timezone)), $this->locale )); } diff --git a/src/Yasumi/Provider/Austria/Burgenland.php b/src/Yasumi/Provider/Austria/Burgenland.php index d9cf6c577..864c3314e 100644 --- a/src/Yasumi/Provider/Austria/Burgenland.php +++ b/src/Yasumi/Provider/Austria/Burgenland.php @@ -1,9 +1,11 @@ year < 1920) { return; @@ -71,7 +73,7 @@ private function calculatePlebisciteDay(): void $this->addHoliday(new Holiday( 'plebisciteDay', [], - new \DateTime($this->year.'-10-10', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-10-10', new \DateTimeZone($this->timezone)), $this->locale )); } diff --git a/src/Yasumi/Provider/Austria/LowerAustria.php b/src/Yasumi/Provider/Austria/LowerAustria.php index 68696edc5..765ab054e 100644 --- a/src/Yasumi/Provider/Austria/LowerAustria.php +++ b/src/Yasumi/Provider/Austria/LowerAustria.php @@ -1,9 +1,11 @@ year < 710) { return; @@ -72,7 +74,7 @@ private function calculateStRupertsDay(): void $this->addHoliday(new Holiday( 'stRupertsDay', [], - new \DateTime($this->year.'-9-24', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-9-24', new \DateTimeZone($this->timezone)), $this->locale )); } diff --git a/src/Yasumi/Provider/Austria/Styria.php b/src/Yasumi/Provider/Austria/Styria.php index bc88f2c0c..81b10f2fa 100644 --- a/src/Yasumi/Provider/Austria/Styria.php +++ b/src/Yasumi/Provider/Austria/Styria.php @@ -1,9 +1,11 @@ year < 304) { return; @@ -73,7 +75,7 @@ private function calculateStFloriansDay(): void $this->addHoliday(new Holiday( 'stFloriansDay', [], - new \DateTime($this->year.'-5-4', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-5-4', new \DateTimeZone($this->timezone)), $this->locale )); } diff --git a/src/Yasumi/Provider/Austria/Vienna.php b/src/Yasumi/Provider/Austria/Vienna.php index 18f83e2a9..6cbc1f219 100644 --- a/src/Yasumi/Provider/Austria/Vienna.php +++ b/src/Yasumi/Provider/Austria/Vienna.php @@ -1,9 +1,11 @@ year >= 1889) { $this->addHoliday(new Holiday( @@ -97,7 +99,7 @@ private function calculateProclamationOfRepublicDay(): void * * @link http://www.johninbrazil.org/all-souls-day-o-dia-dos-finados/ */ - private function calculateAllSoulsDay(): void + protected function calculateAllSoulsDay(): void { if ($this->year >= 1300) { $this->addHoliday(new Holiday( @@ -120,7 +122,7 @@ private function calculateAllSoulsDay(): void * * @link https://en.wikipedia.org/wiki/Our_Lady_of_Aparecida */ - private function calculateOurLadyOfAparecidaDay(): void + protected function calculateOurLadyOfAparecidaDay(): void { if ($this->year >= 1980) { $this->addHoliday(new Holiday( @@ -140,7 +142,7 @@ private function calculateOurLadyOfAparecidaDay(): void * * @link https://en.wikipedia.org/wiki/Independence_of_Brazil */ - private function calculateIndependenceDay(): void + protected function calculateIndependenceDay(): void { if ($this->year >= 1822) { $this->addHoliday(new Holiday( @@ -161,7 +163,7 @@ private function calculateIndependenceDay(): void * * @link https://en.wikipedia.org/wiki/Tiradentes */ - private function calculateTiradentesDay(): void + protected function calculateTiradentesDay(): void { if ($this->year >= 1792) { $this->addHoliday(new Holiday( @@ -181,7 +183,7 @@ private function calculateTiradentesDay(): void * * @link https://en.wikipedia.org/wiki/Brazilian_Carnival */ - private function calculateCarnival(): void + protected function calculateCarnival(): void { if ($this->year >= 1700) { $easter = $this->calculateEaster($this->year, $this->timezone); diff --git a/src/Yasumi/Provider/Canada.php b/src/Yasumi/Provider/Canada.php index e001f71f6..f3cd6b1f7 100644 --- a/src/Yasumi/Provider/Canada.php +++ b/src/Yasumi/Provider/Canada.php @@ -1,9 +1,11 @@ year < 1983) { return; } - $date = new \DateTime($this->year.'-07-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime($this->year . '-07-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)); if (7 === (int) $date->format('N')) { - $date = new \DateTime($this->year.'-07-02', DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime($this->year . '-07-02', DateTimeZoneFactory::getDateTimeZone($this->timezone)); } $this->addHoliday(new Holiday( 'canadaDay', @@ -197,7 +199,7 @@ private function calculateCanadaDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateThanksgivingDay(): void + protected function calculateThanksgivingDay(): void { if ($this->year < 1879) { return; @@ -220,7 +222,7 @@ private function calculateThanksgivingDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateRemembranceDay(): void + protected function calculateRemembranceDay(): void { if ($this->year < 1919) { return; @@ -243,7 +245,7 @@ private function calculateRemembranceDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateLabourDay(): void + protected function calculateLabourDay(): void { if ($this->year < 1894) { return; @@ -266,7 +268,7 @@ private function calculateLabourDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateNationalDayForTruthAndReconciliation(): void + protected function calculateNationalDayForTruthAndReconciliation(): void { if ($this->year < 2021) { return; diff --git a/src/Yasumi/Provider/Canada/Alberta.php b/src/Yasumi/Provider/Canada/Alberta.php index 1e44ef419..b827f8007 100644 --- a/src/Yasumi/Provider/Canada/Alberta.php +++ b/src/Yasumi/Provider/Canada/Alberta.php @@ -1,9 +1,11 @@ year < 1879) { return; diff --git a/src/Yasumi/Provider/Canada/BritishColumbia.php b/src/Yasumi/Provider/Canada/BritishColumbia.php index f712aff28..46931b8ce 100644 --- a/src/Yasumi/Provider/Canada/BritishColumbia.php +++ b/src/Yasumi/Provider/Canada/BritishColumbia.php @@ -1,9 +1,11 @@ year < 2008) { return; diff --git a/src/Yasumi/Provider/Canada/NewBrunswick.php b/src/Yasumi/Provider/Canada/NewBrunswick.php index b885a7c2c..e79d7caba 100644 --- a/src/Yasumi/Provider/Canada/NewBrunswick.php +++ b/src/Yasumi/Provider/Canada/NewBrunswick.php @@ -1,9 +1,11 @@ year < 1971) { return; @@ -78,7 +80,7 @@ private function calculateStPatricksDay(): void $holiday = new Holiday( 'stPatricksDay', ['en' => 'St. Patrick’s Day'], - new \DateTime($this->year.'-3-17', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-3-17', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_BANK ); @@ -113,7 +115,7 @@ private function calculateStPatricksDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateOrangemensDay(): void + protected function calculateOrangemensDay(): void { if ($this->year < 1926) { return; @@ -122,7 +124,7 @@ private function calculateOrangemensDay(): void $holiday = new Holiday( 'orangemensDay', [], - new \DateTime($this->year.'-7-12', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-7-12', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_BANK ); diff --git a/src/Yasumi/Provider/Canada/NorthwestTerritories.php b/src/Yasumi/Provider/Canada/NorthwestTerritories.php index ec1802d76..25662fa73 100644 --- a/src/Yasumi/Provider/Canada/NorthwestTerritories.php +++ b/src/Yasumi/Provider/Canada/NorthwestTerritories.php @@ -1,9 +1,11 @@ year < 2015) { return; diff --git a/src/Yasumi/Provider/Canada/Nunavut.php b/src/Yasumi/Provider/Canada/Nunavut.php index 622de3289..1901e2935 100644 --- a/src/Yasumi/Provider/Canada/Nunavut.php +++ b/src/Yasumi/Provider/Canada/Nunavut.php @@ -1,9 +1,11 @@ year < 2009) { return; @@ -85,7 +87,7 @@ private function calculateIslanderDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateGoldCupParadeDay(): void + protected function calculateGoldCupParadeDay(): void { if ($this->year < 1962) { return; diff --git a/src/Yasumi/Provider/Canada/Quebec.php b/src/Yasumi/Provider/Canada/Quebec.php index fed6d481e..82fa8ef52 100644 --- a/src/Yasumi/Provider/Canada/Quebec.php +++ b/src/Yasumi/Provider/Canada/Quebec.php @@ -1,9 +1,11 @@ year < 2003) { return; diff --git a/src/Yasumi/Provider/Canada/Saskatchewan.php b/src/Yasumi/Provider/Canada/Saskatchewan.php index f9c9c19da..27ec37de4 100644 --- a/src/Yasumi/Provider/Canada/Saskatchewan.php +++ b/src/Yasumi/Provider/Canada/Saskatchewan.php @@ -1,9 +1,11 @@ year < 1879) { return; diff --git a/src/Yasumi/Provider/Canada/Yukon.php b/src/Yasumi/Provider/Canada/Yukon.php index 1e25d04f0..4f489fbc6 100644 --- a/src/Yasumi/Provider/Canada/Yukon.php +++ b/src/Yasumi/Provider/Canada/Yukon.php @@ -1,9 +1,11 @@ year < 1897) { return; @@ -86,7 +88,7 @@ private function calculateDiscoveryDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateHeritageDay(): void + protected function calculateHeritageDay(): void { if ($this->year < 2009) { return; diff --git a/src/Yasumi/Provider/ChristianHolidays.php b/src/Yasumi/Provider/ChristianHolidays.php index b39b39e92..bf982546c 100644 --- a/src/Yasumi/Provider/ChristianHolidays.php +++ b/src/Yasumi/Provider/ChristianHolidays.php @@ -1,9 +1,11 @@ add(new \DateInterval('P'.$easterDays.'D')); + $easter->add(new \DateInterval('P' . $easterDays . 'D')); return $easter; } diff --git a/src/Yasumi/Provider/CommonHolidays.php b/src/Yasumi/Provider/CommonHolidays.php index e4006fb5f..762e84897 100644 --- a/src/Yasumi/Provider/CommonHolidays.php +++ b/src/Yasumi/Provider/CommonHolidays.php @@ -1,9 +1,11 @@ year >= 1991) { $statehoodDayDate = new \DateTime($this->year >= 2020 ? "{$this->year}-5-30" : "{$this->year}-6-25", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -99,7 +101,7 @@ private function calculateStatehoodDay(): void * * @throws \Exception */ - private function calculateHomelandThanksgivingDay(): void + protected function calculateHomelandThanksgivingDay(): void { $names = []; if ($this->year >= 1995 && $this->year < 2020) { @@ -127,7 +129,7 @@ private function calculateHomelandThanksgivingDay(): void * * @throws \Exception */ - private function calculateIndependenceDay(): void + protected function calculateIndependenceDay(): void { if ($this->year < 1991) { return; @@ -149,7 +151,7 @@ private function calculateIndependenceDay(): void * * @throws \Exception */ - private function calculateRemembranceDayForHomelandWarVictims(): void + protected function calculateRemembranceDayForHomelandWarVictims(): void { if ($this->year >= 2020) { $this->addHoliday(new Holiday('remembranceDay', [ @@ -162,7 +164,7 @@ private function calculateRemembranceDayForHomelandWarVictims(): void /* * Day of Antifascist Struggle */ - private function calculateAntiFascistsStruggleDay(): void + protected function calculateAntiFascistsStruggleDay(): void { if ($this->year >= 1941) { $this->addHoliday(new Holiday('antifascistStruggleDay', [ diff --git a/src/Yasumi/Provider/CzechRepublic.php b/src/Yasumi/Provider/CzechRepublic.php index 8486bebc8..4b9718fff 100644 --- a/src/Yasumi/Provider/CzechRepublic.php +++ b/src/Yasumi/Provider/CzechRepublic.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'czechRenewalOfIndependentStateDay', @@ -88,7 +90,7 @@ private function calculateRenewalOfCzechIndependenceDay(): void 'cs' => 'Den obnovy samostatného českého státu', 'en' => 'Day of renewal of the independent Czech state', ], - new \DateTime($this->year.'-01-01', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-01-01', new \DateTimeZone($this->timezone)), $this->locale )); } @@ -113,7 +115,7 @@ private function calculateRenewalOfCzechIndependenceDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSaintsCyrilAndMethodiusDay(): void + protected function calculateSaintsCyrilAndMethodiusDay(): void { $this->addHoliday(new Holiday( 'saintsCyrilAndMethodiusDay', @@ -121,7 +123,7 @@ private function calculateSaintsCyrilAndMethodiusDay(): void 'cs' => 'Den slovanských věrozvěstů Cyrila a Metoděje', 'en' => 'Saints Cyril and Methodius Day', ], - new \DateTime($this->year.'-07-5', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-07-5', new \DateTimeZone($this->timezone)), $this->locale )); } @@ -140,12 +142,12 @@ private function calculateSaintsCyrilAndMethodiusDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateJanHusDay(): void + protected function calculateJanHusDay(): void { $this->addHoliday(new Holiday( 'janHusDay', ['cs' => 'Den upálení mistra Jana Husa', 'en' => 'Jan Hus Day'], - new \DateTime($this->year.'-07-6', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-07-6', new \DateTimeZone($this->timezone)), $this->locale )); } @@ -167,7 +169,7 @@ private function calculateJanHusDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateCzechStatehoodDay(): void + protected function calculateCzechStatehoodDay(): void { $this->addHoliday(new Holiday( 'czechStateHoodDay', @@ -175,7 +177,7 @@ private function calculateCzechStatehoodDay(): void 'cs' => 'Den české státnosti', 'en' => 'St. Wenceslas Day (Czech Statehood Day)', ], - new \DateTime($this->year.'-09-28', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-09-28', new \DateTimeZone($this->timezone)), $this->locale )); } @@ -189,12 +191,12 @@ private function calculateCzechStatehoodDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateIndependentCzechoslovakStateDay(): void + protected function calculateIndependentCzechoslovakStateDay(): void { $this->addHoliday(new Holiday('independentCzechoslovakStateDay', [ 'cs' => 'Den vzniku samostatného československého státu', 'en' => 'Independent Czechoslovak State Day', - ], new \DateTime($this->year.'-10-28', new \DateTimeZone($this->timezone)), $this->locale)); + ], new \DateTime($this->year . '-10-28', new \DateTimeZone($this->timezone)), $this->locale)); } /** @@ -206,7 +208,7 @@ private function calculateIndependentCzechoslovakStateDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateStruggleForFreedomAndDemocracyDay(): void + protected function calculateStruggleForFreedomAndDemocracyDay(): void { $this->addHoliday(new Holiday( 'struggleForFreedomAndDemocracyDay', @@ -214,7 +216,7 @@ private function calculateStruggleForFreedomAndDemocracyDay(): void 'cs' => 'Den boje za svobodu a demokracii', 'en' => 'Struggle for Freedom and Democracy Day', ], - new \DateTime($this->year.'-11-17', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-11-17', new \DateTimeZone($this->timezone)), $this->locale )); } diff --git a/src/Yasumi/Provider/DateTimeZoneFactory.php b/src/Yasumi/Provider/DateTimeZoneFactory.php index 537828770..f09ea23f8 100644 --- a/src/Yasumi/Provider/DateTimeZoneFactory.php +++ b/src/Yasumi/Provider/DateTimeZoneFactory.php @@ -1,9 +1,11 @@ calculateEaster($this->year, $this->timezone)->format('Y-m-d'); @@ -122,7 +124,7 @@ private function calculateGreatPrayerDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateConstitutionDay(): void + protected function calculateConstitutionDay(): void { if ($this->year >= 1849) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Estonia.php b/src/Yasumi/Provider/Estonia.php index c986adf2a..c380ab9a9 100644 --- a/src/Yasumi/Provider/Estonia.php +++ b/src/Yasumi/Provider/Estonia.php @@ -1,9 +1,11 @@ year >= self::DECLARATION_OF_INDEPENDENCE_YEAR) { $this->addHoliday(new Holiday('independenceDay', [ @@ -90,7 +92,7 @@ private function addIndependenceDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addVictoryDay(): void + protected function addVictoryDay(): void { if ($this->year >= self::VICTORY_DAY_START_YEAR) { $this->addHoliday(new Holiday('victoryDay', [ @@ -104,7 +106,7 @@ private function addVictoryDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addRestorationOfIndependenceDay(): void + protected function addRestorationOfIndependenceDay(): void { if ($this->year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) { $this->addHoliday(new Holiday('restorationOfIndependenceDay', [ diff --git a/src/Yasumi/Provider/Finland.php b/src/Yasumi/Provider/Finland.php index 5e205be56..e6ef0f508 100644 --- a/src/Yasumi/Provider/Finland.php +++ b/src/Yasumi/Provider/Finland.php @@ -1,9 +1,11 @@ year < 1955 ? "{$this->year}-6-24" : "{$this->year}-6-20 this saturday"; @@ -123,7 +125,7 @@ private function calculateStJohnsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateAllSaintsDay(): void + protected function calculateAllSaintsDay(): void { $this->addHoliday(new Holiday( 'allSaintsDay', @@ -150,7 +152,7 @@ private function calculateAllSaintsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateIndependenceDay(): void + protected function calculateIndependenceDay(): void { if ($this->year >= 1917) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/France.php b/src/Yasumi/Provider/France.php index 1a548a024..6488ab829 100644 --- a/src/Yasumi/Provider/France.php +++ b/src/Yasumi/Provider/France.php @@ -1,9 +1,11 @@ year >= 1790) { $this->addHoliday(new Holiday('bastilleDay', [ @@ -115,7 +117,7 @@ private function calculateBastilleDay(): void * * @throws \Exception */ - private function calculatePentecostMonday(): void + protected function calculatePentecostMonday(): void { $type = Holiday::TYPE_OFFICIAL; diff --git a/src/Yasumi/Provider/France/BasRhin.php b/src/Yasumi/Provider/France/BasRhin.php index 37d37e635..7b1ccc469 100644 --- a/src/Yasumi/Provider/France/BasRhin.php +++ b/src/Yasumi/Provider/France/BasRhin.php @@ -1,9 +1,11 @@ year}-01-07", new \DateTimeZone($this->timezone)); @@ -101,7 +103,7 @@ private function addOrthodoxChristmasDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addIndependenceDay(): void + protected function addIndependenceDay(): void { if ($this->year >= self::PROCLAMATION_OF_INDEPENDENCE_YEAR) { $date = new \DateTime("{$this->year}-05-26", new \DateTimeZone($this->timezone)); @@ -117,7 +119,7 @@ private function addIndependenceDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addUnityDay(): void + protected function addUnityDay(): void { if ($this->year >= self::APRIL_NINE_TRAGEDY_YEAR) { $date = new \DateTime("{$this->year}-04-09", new \DateTimeZone($this->timezone)); @@ -133,7 +135,7 @@ private function addUnityDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addMothersDay(): void + protected function addMothersDay(): void { $date = new \DateTime("{$this->year}-03-03", new \DateTimeZone($this->timezone)); @@ -147,7 +149,7 @@ private function addMothersDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addVictoryDay(): void + protected function addVictoryDay(): void { $date = new \DateTime("{$this->year}-05-09", new \DateTimeZone($this->timezone)); @@ -161,7 +163,7 @@ private function addVictoryDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addStAndrewsDay(): void + protected function addStAndrewsDay(): void { $date = new \DateTime("{$this->year}-05-12", new \DateTimeZone($this->timezone)); @@ -175,7 +177,7 @@ private function addStAndrewsDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addOrthodoxEpiphanyDay(): void + protected function addOrthodoxEpiphanyDay(): void { $date = new \DateTime("{$this->year}-01-19", new \DateTimeZone($this->timezone)); @@ -189,7 +191,7 @@ private function addOrthodoxEpiphanyDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addStMarysDay(): void + protected function addStMarysDay(): void { $date = new \DateTime("{$this->year}-08-28", new \DateTimeZone($this->timezone)); @@ -203,7 +205,7 @@ private function addStMarysDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addMtskhetobaDay(): void + protected function addMtskhetobaDay(): void { $date = new \DateTime("{$this->year}-10-14", new \DateTimeZone($this->timezone)); @@ -217,7 +219,7 @@ private function addMtskhetobaDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addStGeorgesDay(): void + protected function addStGeorgesDay(): void { $date = new \DateTime("{$this->year}-11-23", new \DateTimeZone($this->timezone)); @@ -231,7 +233,7 @@ private function addStGeorgesDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addSecondNewYearDay(): void + protected function addSecondNewYearDay(): void { $date = new \DateTime("{$this->year}-01-02", new \DateTimeZone($this->timezone)); diff --git a/src/Yasumi/Provider/Germany.php b/src/Yasumi/Provider/Germany.php index 654a4c2c2..2fb294a58 100644 --- a/src/Yasumi/Provider/Germany.php +++ b/src/Yasumi/Provider/Germany.php @@ -1,9 +1,11 @@ addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale)); $this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale)); $this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale)); - $this->addHoliday($this->pentecost($this->year, $this->timezone, $this->locale)); + $this->addHoliday($this->pentecost($this->year, $this->timezone, $this->locale, Holiday::TYPE_OTHER)); $this->addHoliday($this->pentecostMonday($this->year, $this->timezone, $this->locale)); $this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale)); @@ -90,13 +92,13 @@ public function getSources(): array * @throws UnknownLocaleException * @throws \Exception */ - private function calculateGermanUnityDay(): void + protected function calculateGermanUnityDay(): void { if ($this->year >= 1990) { $this->addHoliday(new Holiday( 'germanUnityDay', ['de' => 'Tag der Deutschen Einheit'], - new \DateTime($this->year.'-10-3', new \DateTimeZone($this->timezone)), + new \DateTime($this->year . '-10-3', new \DateTimeZone($this->timezone)), $this->locale )); } diff --git a/src/Yasumi/Provider/Germany/BadenWurttemberg.php b/src/Yasumi/Provider/Germany/BadenWurttemberg.php index 678710d4e..57eec668c 100644 --- a/src/Yasumi/Provider/Germany/BadenWurttemberg.php +++ b/src/Yasumi/Provider/Germany/BadenWurttemberg.php @@ -1,9 +1,11 @@ addHoliday($this->epiphany($this->year, $this->timezone, $this->locale)); $this->addHoliday($this->corpusChristi($this->year, $this->timezone, $this->locale, Holiday::TYPE_OFFICIAL)); $this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale)); + $this->addHoliday($this->assumptionOfMary($this->year, $this->timezone, $this->locale, Holiday::TYPE_OTHER)); } } diff --git a/src/Yasumi/Provider/Germany/Berlin.php b/src/Yasumi/Provider/Germany/Berlin.php index 092839582..033a7e001 100644 --- a/src/Yasumi/Provider/Germany/Berlin.php +++ b/src/Yasumi/Provider/Germany/Berlin.php @@ -1,8 +1,11 @@ year < 1517) { return; diff --git a/src/Yasumi/Provider/Germany/Bremen.php b/src/Yasumi/Provider/Germany/Bremen.php index 074fa2c1d..341888d8d 100644 --- a/src/Yasumi/Provider/Germany/Bremen.php +++ b/src/Yasumi/Provider/Germany/Bremen.php @@ -1,8 +1,11 @@ year < 2018) { return; diff --git a/src/Yasumi/Provider/Germany/Hamburg.php b/src/Yasumi/Provider/Germany/Hamburg.php index 019896fbf..bd3ca9296 100644 --- a/src/Yasumi/Provider/Germany/Hamburg.php +++ b/src/Yasumi/Provider/Germany/Hamburg.php @@ -1,8 +1,11 @@ year < 2018) { return; diff --git a/src/Yasumi/Provider/Germany/Hesse.php b/src/Yasumi/Provider/Germany/Hesse.php index afbff3bbf..a0693f10c 100644 --- a/src/Yasumi/Provider/Germany/Hesse.php +++ b/src/Yasumi/Provider/Germany/Hesse.php @@ -1,8 +1,11 @@ year < 2018) { return; diff --git a/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php b/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php index 549c54542..8ef8be4f8 100644 --- a/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php +++ b/src/Yasumi/Provider/Germany/MecklenburgWesternPomerania.php @@ -1,8 +1,11 @@ year < 1517) { return; diff --git a/src/Yasumi/Provider/Germany/NorthRhineWestphalia.php b/src/Yasumi/Provider/Germany/NorthRhineWestphalia.php index a8843929b..61e9f8efd 100644 --- a/src/Yasumi/Provider/Germany/NorthRhineWestphalia.php +++ b/src/Yasumi/Provider/Germany/NorthRhineWestphalia.php @@ -1,8 +1,11 @@ year < 1517) { return; @@ -85,7 +88,7 @@ private function calculateReformationDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateRepentanceAndPrayerDay(): void + protected function calculateRepentanceAndPrayerDay(): void { if ($this->year >= 1995) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Germany/SaxonyAnhalt.php b/src/Yasumi/Provider/Germany/SaxonyAnhalt.php index 849038769..679cd8ffd 100644 --- a/src/Yasumi/Provider/Germany/SaxonyAnhalt.php +++ b/src/Yasumi/Provider/Germany/SaxonyAnhalt.php @@ -1,8 +1,11 @@ year < 1517) { return; diff --git a/src/Yasumi/Provider/Germany/SchleswigHolstein.php b/src/Yasumi/Provider/Germany/SchleswigHolstein.php index 253272611..fed781b66 100644 --- a/src/Yasumi/Provider/Germany/SchleswigHolstein.php +++ b/src/Yasumi/Provider/Germany/SchleswigHolstein.php @@ -1,8 +1,11 @@ year < 2018) { return; diff --git a/src/Yasumi/Provider/Germany/Thuringia.php b/src/Yasumi/Provider/Germany/Thuringia.php index fa7adec4d..a6b99513b 100644 --- a/src/Yasumi/Provider/Germany/Thuringia.php +++ b/src/Yasumi/Provider/Germany/Thuringia.php @@ -1,8 +1,11 @@ year < 1517) { return; @@ -77,7 +80,7 @@ private function calculateReformationDay(): void * * @throws \Exception */ - private function calculateWorldChildrensDay(): void + protected function calculateWorldChildrensDay(): void { if ($this->year < 2019) { return; diff --git a/src/Yasumi/Provider/Greece.php b/src/Yasumi/Provider/Greece.php index 1193eed7d..45a5b419f 100644 --- a/src/Yasumi/Provider/Greece.php +++ b/src/Yasumi/Provider/Greece.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'threeHolyHierarchs', @@ -111,7 +113,7 @@ private function calculateThreeHolyHierarchs(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateCleanMonday(): void + protected function calculateCleanMonday(): void { $holiday = 'cleanMonday'; $date = $this->calculateEaster($this->year, $this->timezone)->sub(new \DateInterval('P48D')); @@ -132,7 +134,7 @@ private function calculateCleanMonday(): void * * @throws \Exception */ - private function calculateEaster(int $year, string $timezone): \DateTimeInterface + protected function calculateEaster(int $year, string $timezone): \DateTimeInterface { return $this->calculateOrthodoxEaster($year, $timezone); } @@ -148,7 +150,7 @@ private function calculateEaster(int $year, string $timezone): \DateTimeInterfac * @throws UnknownLocaleException * @throws \Exception */ - private function calculateIndependenceDay(): void + protected function calculateIndependenceDay(): void { if ($this->year >= 1821) { $this->addHoliday(new Holiday( @@ -171,7 +173,7 @@ private function calculateIndependenceDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateOhiDay(): void + protected function calculateOhiDay(): void { if ($this->year >= 1940) { $this->addHoliday(new Holiday( @@ -194,7 +196,7 @@ private function calculateOhiDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculatePolytechnio(): void + protected function calculatePolytechnio(): void { if ($this->year >= 1973) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Hungary.php b/src/Yasumi/Provider/Hungary.php index f455af8b5..ba2c5b697 100644 --- a/src/Yasumi/Provider/Hungary.php +++ b/src/Yasumi/Provider/Hungary.php @@ -1,9 +1,11 @@ + */ + +namespace Yasumi\Provider; + +use Yasumi\Exception\UnknownLocaleException; +use Yasumi\Holiday; + +/** + * Note: Any Islamic holidays are not part of this provider yet. Islamic holidays are quite complex and at first, + * only Jalali holidays are implemented. + */ +class Iran extends AbstractProvider +{ + /** {@inheritdoc} */ + public const ID = 'IR'; + + /** + * @throws \InvalidArgumentException + * @throws UnknownLocaleException + * @throws \Exception + */ + public function initialize(): void + { + $this->timezone = 'Asia/Tehran'; + + $this->addNowruz(); + $this->addIslamicRepublicDay(); + $this->addSizdahBedar(); + $this->addDeathOfKhomeini(); + $this->addRevoltOfKhordad15(); + $this->addAnniversaryOfIslamicRevolution(); + $this->addNationalizationOfTheIranianOilIndustry(); + } + + public function getSources(): array + { + return [ + 'https://en.wikipedia.org/wiki/Public_holidays_in_Iran', + 'https://fa.wikipedia.org/wiki/%D8%AA%D8%B9%D8%B7%DB%8C%D9%84%D8%A7%D8%AA_%D8%B1%D8%B3%D9%85%DB%8C_%D8%AF%D8%B1_%D8%A7%DB%8C%D8%B1%D8%A7%D9%86', + ]; + } + + protected function addNowruz(): void + { + foreach ([21, 22, 23, 24] as $index => $day) { + ++$index; + $this->addHoliday(new Holiday("nowruz{$index}", [ + 'en' => 'Nowruz', + 'fa' => 'نوروز', + ], new \DateTime("{$this->year}-03-{$day}", new \DateTimeZone($this->timezone)), $this->locale)); + } + } + + /** + * The day usually falls on 1 April, however, as it is determined by the vernal equinox, the date can change if the equinox does not fall on 21 March. + * In 2016, it was on 31 March, and in 2017, 2019, 2021, 2022 and 2023 the date was back to 1 April. + * + * @see https://en.wikipedia.org/wiki/Iranian_Islamic_Republic_Day + * + * @throws \Exception + */ + protected function addIslamicRepublicDay(): void + { + if (1979 > $this->year) { + return; + } + + $month = '04'; + $day = '01'; + + if (2016 === $this->year) { + $month = '03'; + $day = '31'; + } + + $this->addHoliday(new Holiday('islamicRepublicDay', [ + 'en' => 'Ruz e Jomhuri ye Eslami', + 'fa' => 'روز جمهوری اسلامی', + ], new \DateTime("{$this->year}-{$month}-{$day}", new \DateTimeZone($this->timezone)), $this->locale)); + } + + protected function addSizdahBedar(): void + { + $this->addHoliday(new Holiday('sizdahBedar', [ + 'en' => 'Sizdah be dar', + 'fa' => 'سیزده بدر', + ], new \DateTime("{$this->year}-04-02", new \DateTimeZone($this->timezone)), $this->locale)); + } + + protected function addDeathOfKhomeini(): void + { + if (1989 > $this->year) { + return; + } + + $this->addHoliday(new Holiday('deathOfKhomeini', [ + 'en' => 'Marg e Khomeini', + 'fa' => 'مرگ خمینی', + ], new \DateTime("{$this->year}-06-04", new \DateTimeZone($this->timezone)), $this->locale)); + } + + protected function addRevoltOfKhordad15(): void + { + if (1979 > $this->year) { + return; + } + + $this->addHoliday(new Holiday('revoltOfKhordad15', [ + 'en' => 'Qiam e Panzdah e Khordad', + 'fa' => 'قیام ۱۵ خرداد', + ], new \DateTime("{$this->year}-06-05", new \DateTimeZone($this->timezone)), $this->locale)); + } + + protected function addAnniversaryOfIslamicRevolution(): void + { + if (1979 > $this->year) { + return; + } + + $this->addHoliday(new Holiday('anniversaryOfIslamicRevolution', [ + 'en' => 'Enqelab e Eslami', + 'fa' => 'انقلاب اسلامی پنجاه و هفت', + ], new \DateTime("{$this->year}-02-11", new \DateTimeZone($this->timezone)), $this->locale)); + } + + protected function addNationalizationOfTheIranianOilIndustry(): void + { + if (1951 > $this->year) { + return; + } + + $this->addHoliday(new Holiday('nationalizationOfTheIranianOilIndustry', [ + 'en' => 'Melli Shodan e Saneat e Naft', + 'fa' => 'ملی شدن صنعت نفت', + ], new \DateTime("{$this->year}-03-20", new \DateTimeZone($this->timezone)), $this->locale)); + } +} diff --git a/src/Yasumi/Provider/Ireland.php b/src/Yasumi/Provider/Ireland.php index 998b8d401..05eeabeeb 100644 --- a/src/Yasumi/Provider/Ireland.php +++ b/src/Yasumi/Provider/Ireland.php @@ -1,9 +1,11 @@ year < 1974) { return; @@ -134,7 +136,7 @@ private function calculateNewYearsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculatePentecostMonday(): void + protected function calculatePentecostMonday(): void { if ($this->year > 1973) { return; @@ -155,12 +157,12 @@ private function calculatePentecostMonday(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateChristmasDay(): void + protected function calculateChristmasDay(): void { $holiday = new Holiday( 'christmasDay', ['en' => 'Christmas Day', 'ga' => 'Lá Nollag'], - new \DateTime($this->year.'-12-25', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-12-25', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale ); @@ -193,12 +195,12 @@ private function calculateChristmasDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateStStephensDay(): void + protected function calculateStStephensDay(): void { $holiday = new Holiday( 'stStephensDay', [], - new \DateTime($this->year.'-12-26', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-12-26', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale ); @@ -233,7 +235,7 @@ private function calculateStStephensDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateStPatricksDay(): void + protected function calculateStPatricksDay(): void { if ($this->year < 1903) { return; @@ -241,7 +243,7 @@ private function calculateStPatricksDay(): void $holiday = new Holiday( 'stPatricksDay', ['en' => 'St. Patrick’s Day', 'ga' => 'Lá Fhéile Pádraig'], - new \DateTime($this->year.'-3-17', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-3-17', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale ); @@ -276,7 +278,7 @@ private function calculateStPatricksDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateMayDay(): void + protected function calculateMayDay(): void { if ($this->year < 1994) { return; @@ -302,7 +304,7 @@ private function calculateMayDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateJuneHoliday(): void + protected function calculateJuneHoliday(): void { if ($this->year < 1974) { return; @@ -327,7 +329,7 @@ private function calculateJuneHoliday(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateOctoberHoliday(): void + protected function calculateOctoberHoliday(): void { if ($this->year < 1977) { return; diff --git a/src/Yasumi/Provider/Italy.php b/src/Yasumi/Provider/Italy.php index cab081509..fa1521b7b 100644 --- a/src/Yasumi/Provider/Italy.php +++ b/src/Yasumi/Provider/Italy.php @@ -1,9 +1,11 @@ year >= 1949) { $this->addHoliday(new Holiday( @@ -111,7 +113,7 @@ private function calculateLiberationDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateRepublicDay(): void + protected function calculateRepublicDay(): void { if ($this->year >= 1946) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Japan.php b/src/Yasumi/Provider/Japan.php index 3230f28f3..ffd5c66c7 100644 --- a/src/Yasumi/Provider/Japan.php +++ b/src/Yasumi/Provider/Japan.php @@ -1,9 +1,11 @@ year >= 1966) { $this->addHoliday(new Holiday( @@ -138,7 +140,7 @@ private function calculateNationalFoundationDay(): void * * @throws \Exception */ - private function calculateShowaDay(): void + protected function calculateShowaDay(): void { if ($this->year >= 2007) { $this->addHoliday(new Holiday( @@ -158,7 +160,7 @@ private function calculateShowaDay(): void * * @throws \Exception */ - private function calculateConstitutionMemorialDay(): void + protected function calculateConstitutionMemorialDay(): void { if ($this->year >= 1948) { $this->addHoliday(new Holiday( @@ -178,7 +180,7 @@ private function calculateConstitutionMemorialDay(): void * * @throws \Exception */ - private function calculateChildrensDay(): void + protected function calculateChildrensDay(): void { if ($this->year >= 1948) { $this->addHoliday(new Holiday( @@ -198,7 +200,7 @@ private function calculateChildrensDay(): void * * @throws \Exception */ - private function calculateCultureDay(): void + protected function calculateCultureDay(): void { if ($this->year >= 1948) { $this->addHoliday(new Holiday( @@ -215,7 +217,7 @@ private function calculateCultureDay(): void * * @throws \Exception */ - private function calculateLaborThanksgivingDay(): void + protected function calculateLaborThanksgivingDay(): void { if ($this->year >= 1948) { $this->addHoliday(new Holiday( @@ -235,7 +237,7 @@ private function calculateLaborThanksgivingDay(): void * * @throws \Exception */ - private function calculateEmperorsBirthday(): void + protected function calculateEmperorsBirthday(): void { $emperorsBirthday = null; if ($this->year >= 2020) { @@ -269,7 +271,7 @@ private function calculateEmperorsBirthday(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateVernalEquinoxDay(): void + protected function calculateVernalEquinoxDay(): void { $day = null; if ($this->year >= 1948 && $this->year <= 1979) { @@ -304,7 +306,7 @@ private function calculateVernalEquinoxDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateComingOfAgeDay(): void + protected function calculateComingOfAgeDay(): void { if ($this->year >= 1948) { $date = $this->year >= 2000 ? @@ -329,7 +331,7 @@ private function calculateComingOfAgeDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateGreeneryDay(): void + protected function calculateGreeneryDay(): void { $date = null; if ($this->year >= 2007) { @@ -358,7 +360,7 @@ private function calculateGreeneryDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateMarineDay(): void + protected function calculateMarineDay(): void { if (1996 > $this->year) { return; @@ -397,7 +399,7 @@ private function calculateMarineDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateMountainDay(): void + protected function calculateMountainDay(): void { $date = null; if (2021 === $this->year) { @@ -430,7 +432,7 @@ private function calculateMountainDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateRespectForTheAgeDay(): void + protected function calculateRespectForTheAgeDay(): void { $date = null; if ($this->year >= 2003) { @@ -459,7 +461,7 @@ private function calculateRespectForTheAgeDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSportsDay(): void + protected function calculateSportsDay(): void { $date = null; if (2021 === $this->year) { @@ -502,7 +504,7 @@ private function calculateSportsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateAutumnalEquinoxDay(): void + protected function calculateAutumnalEquinoxDay(): void { $day = null; if ($this->year >= 1948 && $this->year <= 1979) { @@ -537,7 +539,7 @@ private function calculateAutumnalEquinoxDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSubstituteHolidays(): void + protected function calculateSubstituteHolidays(): void { // Get initial list of holiday dates $dates = $this->getHolidayDates(); @@ -584,7 +586,7 @@ private function calculateSubstituteHolidays(): void * * @throws \Exception */ - private function calculateCoronationDay(): void + protected function calculateCoronationDay(): void { if (2019 === $this->year) { $this->addHoliday(new Holiday( @@ -602,7 +604,7 @@ private function calculateCoronationDay(): void * * @throws \Exception */ - private function calculateEnthronementProclamationCeremony(): void + protected function calculateEnthronementProclamationCeremony(): void { if (2019 === $this->year) { $this->addHoliday(new Holiday( @@ -623,7 +625,7 @@ private function calculateEnthronementProclamationCeremony(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateBridgeHolidays(): void + protected function calculateBridgeHolidays(): void { // Get initial list of holidays and iterator $datesIterator = $this->getIterator(); @@ -648,7 +650,7 @@ private function calculateBridgeHolidays(): void $bridgeDate = clone $previous; $bridgeDate->add(new \DateInterval('P1D')); - $this->addHoliday(new Holiday('bridgeDay'.$counter, [ + $this->addHoliday(new Holiday('bridgeDay' . $counter, [ 'en' => 'Bridge Public holiday', 'ja' => '国民の休日', ], $bridgeDate, $this->locale)); diff --git a/src/Yasumi/Provider/Latvia.php b/src/Yasumi/Provider/Latvia.php index 4b3b6da3e..fde07e6d2 100644 --- a/src/Yasumi/Provider/Latvia.php +++ b/src/Yasumi/Provider/Latvia.php @@ -1,9 +1,11 @@ year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) { $date = new \DateTime("{$this->year}-05-04", new \DateTimeZone($this->timezone)); @@ -98,7 +100,7 @@ private function addRestorationOfIndependenceDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addMidsummerEveDay(): void + protected function addMidsummerEveDay(): void { $this->addHoliday(new Holiday('midsummerEveDay', [ 'en' => 'Midsummer Eve', @@ -113,7 +115,7 @@ private function addMidsummerEveDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addProclamationDay(): void + protected function addProclamationDay(): void { if ($this->year >= self::PROCLAMATION_OF_INDEPENDENCE_YEAR) { $date = new \DateTime("{$this->year}-11-18", new \DateTimeZone($this->timezone)); diff --git a/src/Yasumi/Provider/Lithuania.php b/src/Yasumi/Provider/Lithuania.php index 3827b8320..e03033157 100644 --- a/src/Yasumi/Provider/Lithuania.php +++ b/src/Yasumi/Provider/Lithuania.php @@ -1,9 +1,11 @@ year >= self::RESTORATION_OF_THE_STATE_YEAR) { $this->addHoliday(new Holiday('restorationOfTheStateOfLithuaniaDay', [ @@ -110,7 +112,7 @@ private function addRestorationOfTheStateDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addRestorationOfIndependenceDay(): void + protected function addRestorationOfIndependenceDay(): void { if ($this->year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) { $this->addHoliday(new Holiday('restorationOfIndependenceOfLithuaniaDay', [ @@ -127,7 +129,7 @@ private function addRestorationOfIndependenceDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addStatehoodDay(): void + protected function addStatehoodDay(): void { if ($this->year >= self::STATEHOOD_YEAR) { $this->addHoliday(new Holiday('statehoodDay', [ @@ -143,7 +145,7 @@ private function addStatehoodDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addAllSoulsDay(): void + protected function addAllSoulsDay(): void { if ($this->year >= self::ALL_SOULS_DAY) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Luxembourg.php b/src/Yasumi/Provider/Luxembourg.php index 9700b5b9e..7f2393880 100644 --- a/src/Yasumi/Provider/Luxembourg.php +++ b/src/Yasumi/Provider/Luxembourg.php @@ -10,7 +10,20 @@ * @author Sacha Telgenhof */ -declare(strict_types=1); +declare(strict_types = 1); + +/** + * This file is part of the 'Yasumi' package. + * + * The easy PHP Library for calculating holidays. + * + * Copyright (c) 2015 - 2024 AzuyaLabs + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * @author Sacha Telgenhof + */ namespace Yasumi\Provider; @@ -81,7 +94,7 @@ public function getSources(): array * @throws UnknownLocaleException * @throws \Exception */ - private function calculateEuropeDay(): void + protected function calculateEuropeDay(): void { if ($this->year >= 2019) { $this->addHoliday(new Holiday('europeDay', [ @@ -106,7 +119,7 @@ private function calculateEuropeDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateNationalDay(): void + protected function calculateNationalDay(): void { $this->addHoliday(new Holiday('nationalDay', [ 'en_US' => 'National day', diff --git a/src/Yasumi/Provider/Mexico.php b/src/Yasumi/Provider/Mexico.php index 3beb222f2..971f59078 100644 --- a/src/Yasumi/Provider/Mexico.php +++ b/src/Yasumi/Provider/Mexico.php @@ -1,11 +1,11 @@ year >= 1810) { $this->addHoliday(new Holiday( @@ -112,7 +112,7 @@ private function addIndependenceDay(): void * * Anniversary of the Constitution of 1917, originally February 5, observed on the first Monday of February. */ - private function calculateConstitutionDay(): void + protected function calculateConstitutionDay(): void { if ($this->year >= 1917) { $this->addHoliday(new Holiday( @@ -131,7 +131,7 @@ private function calculateConstitutionDay(): void * * Anniversary of the birth of Benito Juárez on March 21, 1806, observed on the third Monday of March. */ - private function calculateBenitoJuarezBirthday(): void + protected function calculateBenitoJuarezBirthday(): void { if ($this->year >= 1806 && $this->year < 2010) { $this->addHoliday(new Holiday( @@ -161,7 +161,7 @@ private function calculateBenitoJuarezBirthday(): void * * Anniversary of the start of the Mexican Revolution on November 20, 1910, observed on the third Monday of November. */ - private function calculateRevolutionDay(): void + protected function calculateRevolutionDay(): void { if ($this->year >= 1910) { $this->addHoliday(new Holiday( @@ -180,7 +180,7 @@ private function calculateRevolutionDay(): void * * Anniversary of the Discovery of America on October 12, 1492, observed on the second Monday of October. */ - private function calculateDiscoveryOfAmerica(): void + protected function calculateDiscoveryOfAmerica(): void { if ($this->year >= 1492) { $this->addHoliday(new Holiday( @@ -200,7 +200,7 @@ private function calculateDiscoveryOfAmerica(): void * Christmas Eve is the day before Christmas Day, which is annually on December 24, according to the Gregorian * calendar. */ - private function calculateChristmasEve(): void + protected function calculateChristmasEve(): void { $this->addHoliday(new Holiday( 'christmasEve', @@ -217,7 +217,7 @@ private function calculateChristmasEve(): void * * New Year's Eve is the last day of the year, December 31, in the Gregorian calendar. */ - private function calculateNewYearsEve(): void + protected function calculateNewYearsEve(): void { $this->addHoliday(new Holiday( 'newYearsEve', @@ -235,7 +235,7 @@ private function calculateNewYearsEve(): void * Day of the Deaths is a Mexican holiday celebrated throughout Mexico, in particular the Central and South regions, * and by people of Mexican heritage elsewhere. */ - private function calculateDayOfTheDead(): void + protected function calculateDayOfTheDead(): void { if ($this->year >= 1800) { $this->addHoliday(new Holiday( @@ -255,7 +255,7 @@ private function calculateDayOfTheDead(): void * The Virgin of Guadalupe (Día de la Virgen de Guadalupe) is a celebration of the Virgin Mary, * who is the patron saint of Mexico. It is observed on December 12th. */ - private function calculateVirginOfGuadalupe(): void + protected function calculateVirginOfGuadalupe(): void { if ($this->year >= 1531) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Netherlands.php b/src/Yasumi/Provider/Netherlands.php index 94003b53d..eabb0c949 100644 --- a/src/Yasumi/Provider/Netherlands.php +++ b/src/Yasumi/Provider/Netherlands.php @@ -1,9 +1,11 @@ calculateEaster($this->year, $this->timezone); @@ -140,7 +142,7 @@ private function calculateCarnival(): void * * @throws \Exception */ - private function calculateStNicholasDay(): void + protected function calculateStNicholasDay(): void { /* * St. Nicholas' Day @@ -166,7 +168,7 @@ private function calculateStNicholasDay(): void * * @throws \Exception */ - private function calculateHalloween(): void + protected function calculateHalloween(): void { $this->addHoliday(new Holiday( 'halloween', @@ -185,7 +187,7 @@ private function calculateHalloween(): void * * @throws \Exception */ - private function calculatePrincesDay(): void + protected function calculatePrincesDay(): void { $this->addHoliday(new Holiday( 'princesDay', @@ -205,7 +207,7 @@ private function calculatePrincesDay(): void * * @throws \Exception */ - private function calculateQueensday(): void + protected function calculateQueensday(): void { if ($this->year >= 1891 && $this->year <= 2013) { $date = new \DateTime("{$this->year}-4-30", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -235,7 +237,7 @@ private function calculateQueensday(): void * * @throws \Exception */ - private function calculateKingsday(): void + protected function calculateKingsday(): void { if ($this->year >= 2014) { $date = new \DateTime("{$this->year}-4-27", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -260,7 +262,7 @@ private function calculateKingsday(): void * * @throws \Exception */ - private function calculateCommemorationLiberationDay(): void + protected function calculateCommemorationLiberationDay(): void { if ($this->year >= 1947) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/NewZealand.php b/src/Yasumi/Provider/NewZealand.php index 8f3261997..5c6c1f249 100644 --- a/src/Yasumi/Provider/NewZealand.php +++ b/src/Yasumi/Provider/NewZealand.php @@ -1,9 +1,11 @@ year}-01-01", DateTimeZoneFactory::getDateTimeZone($this->timezone)); $dayAfterNewYearsDay = new \DateTime("{$this->year}-01-02", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -117,7 +119,7 @@ private function calculateNewYearHolidays(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateWaitangiDay(): void + protected function calculateWaitangiDay(): void { if ($this->year < 1974) { return; @@ -146,7 +148,7 @@ private function calculateWaitangiDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateAnzacDay(): void + protected function calculateAnzacDay(): void { if ($this->year < 1921) { return; @@ -178,7 +180,7 @@ private function calculateAnzacDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateQueensBirthday(): void + protected function calculateQueensBirthday(): void { if ($this->year < 1952) { return; @@ -210,14 +212,14 @@ private function calculateQueensBirthday(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateLabourDay(): void + protected function calculateLabourDay(): void { if ($this->year < 1900) { return; } $date = new \DateTime( - ($this->year < 1910 ? 'second wednesday of october' : 'fourth monday of october')." {$this->year}", + ($this->year < 1910 ? 'second wednesday of october' : 'fourth monday of october') . " {$this->year}", DateTimeZoneFactory::getDateTimeZone($this->timezone) ); @@ -238,7 +240,7 @@ private function calculateLabourDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateChristmasHolidays(): void + protected function calculateChristmasHolidays(): void { $christmasDay = new \DateTime("{$this->year}-12-25", DateTimeZoneFactory::getDateTimeZone($this->timezone)); $boxingDay = new \DateTime("{$this->year}-12-26", DateTimeZoneFactory::getDateTimeZone($this->timezone)); diff --git a/src/Yasumi/Provider/Norway.php b/src/Yasumi/Provider/Norway.php index db911d959..82c79806b 100644 --- a/src/Yasumi/Provider/Norway.php +++ b/src/Yasumi/Provider/Norway.php @@ -1,9 +1,11 @@ year >= 1836) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Poland.php b/src/Yasumi/Provider/Poland.php index 9c972386d..69bdd7d06 100644 --- a/src/Yasumi/Provider/Poland.php +++ b/src/Yasumi/Provider/Poland.php @@ -1,9 +1,11 @@ year < 1918) { return; @@ -111,7 +113,7 @@ private function calculateIndependenceDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateConstitutionDay(): void + protected function calculateConstitutionDay(): void { if ($this->year < 1791) { return; diff --git a/src/Yasumi/Provider/Portugal.php b/src/Yasumi/Provider/Portugal.php index 8f60e25d2..8945ab910 100644 --- a/src/Yasumi/Provider/Portugal.php +++ b/src/Yasumi/Provider/Portugal.php @@ -1,9 +1,11 @@ year >= 1974) { $this->addHoliday(new Holiday( @@ -107,7 +109,7 @@ private function calculateCarnationRevolutionDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateCorpusChristi(): void + protected function calculateCorpusChristi(): void { if ($this->year <= 2012 || $this->year >= 2016) { $this->addHoliday($this->corpusChristi($this->year, $this->timezone, $this->locale)); @@ -131,7 +133,7 @@ private function calculateCorpusChristi(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculatePortugalDay(): void + protected function calculatePortugalDay(): void { if ($this->year <= 1932 || $this->year >= 1974) { $this->addHoliday(new Holiday( @@ -164,7 +166,7 @@ private function calculatePortugalDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculatePortugueseRepublicDay(): void + protected function calculatePortugueseRepublicDay(): void { if (($this->year >= 1910 && $this->year <= 2012) || $this->year >= 2016) { $this->addHoliday(new Holiday( @@ -184,7 +186,7 @@ private function calculatePortugueseRepublicDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateAllSaintsDay(): void + protected function calculateAllSaintsDay(): void { if ($this->year <= 2012 || $this->year >= 2016) { $this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale)); @@ -217,7 +219,7 @@ private function calculateAllSaintsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateRestorationOfIndependenceDay(): void + protected function calculateRestorationOfIndependenceDay(): void { // The Wikipedia article mentions that this has been a holiday since the second of half of the XIX century. if (($this->year >= 1850 && $this->year <= 2012) || $this->year >= 2016) { diff --git a/src/Yasumi/Provider/Romania.php b/src/Yasumi/Provider/Romania.php index ff0e00e27..4a145a82a 100644 --- a/src/Yasumi/Provider/Romania.php +++ b/src/Yasumi/Provider/Romania.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'dayAfterNewYearsDay', @@ -131,7 +133,7 @@ private function calculateDayAfterNewYearsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateUnitedPrincipalitiesDay(): void + protected function calculateUnitedPrincipalitiesDay(): void { // The law is official since 21.12.2014. if ($this->year > 2014) { @@ -153,13 +155,13 @@ private function calculateUnitedPrincipalitiesDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateStAndrewDay(): void + protected function calculateStAndrewDay(): void { if ($this->year >= 2012) { $this->addHoliday(new Holiday( 'stAndrewsDay', [], - new \DateTime($this->year.'-11-30', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-11-30', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale )); } @@ -180,7 +182,7 @@ private function calculateStAndrewDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateNationalDay(): void + protected function calculateNationalDay(): void { $nationalDay = null; @@ -216,13 +218,13 @@ private function calculateNationalDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateStJohnsDay(): void + protected function calculateStJohnsDay(): void { if ($this->year >= 2024) { $this->addHoliday(new Holiday( 'stJohnsDay', [], - new \DateTime($this->year.'-01-07', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-01-07', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale )); } @@ -239,7 +241,7 @@ private function calculateStJohnsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateConstantinBrancusiDay(): void + protected function calculateConstantinBrancusiDay(): void { if ($this->year >= 2016) { $this->addHoliday(new Holiday( @@ -267,7 +269,7 @@ private function calculateConstantinBrancusiDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateChildrensDay(): void + protected function calculateChildrensDay(): void { if ($this->year >= 1950 && $this->year <= 2016) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Russia.php b/src/Yasumi/Provider/Russia.php index 5c976d07a..90146706f 100644 --- a/src/Yasumi/Provider/Russia.php +++ b/src/Yasumi/Provider/Russia.php @@ -1,9 +1,11 @@ addHoliday(new Holiday('newYearHolidaysDay'.$day, [ + $this->addHoliday(new Holiday('newYearHolidaysDay' . $day, [ 'en' => 'New Year’s holidays', 'ru' => 'Новогодние каникулы', ], new \DateTime("{$this->year}-01-{$day}", new \DateTimeZone($this->timezone)), $this->locale)); @@ -88,7 +90,7 @@ private function addNewYearsHolidays(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addOrthodoxChristmasDay(): void + protected function addOrthodoxChristmasDay(): void { $this->addHoliday(new Holiday('orthodoxChristmasDay', [ 'en' => 'Orthodox Christmas Day', @@ -100,7 +102,7 @@ private function addOrthodoxChristmasDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addDefenceOfTheFatherlandDay(): void + protected function addDefenceOfTheFatherlandDay(): void { if ($this->year < self::DEFENCE_OF_THE_FATHERLAND_START_YEAR) { return; @@ -116,7 +118,7 @@ private function addDefenceOfTheFatherlandDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addInternationalWomensDay(): void + protected function addInternationalWomensDay(): void { $this->addHoliday($this->internationalWomensDay($this->year, $this->timezone, $this->locale)); } @@ -125,7 +127,7 @@ private function addInternationalWomensDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addSpringAndLabourDay(): void + protected function addSpringAndLabourDay(): void { $this->addHoliday(new Holiday('springAndLabourDay', [ 'en' => 'Spring and Labour Day', @@ -137,7 +139,7 @@ private function addSpringAndLabourDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addVictoryDay(): void + protected function addVictoryDay(): void { $this->addHoliday(new Holiday('victoryDay', [ 'en' => 'Victory Day', @@ -149,7 +151,7 @@ private function addVictoryDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addRussiaDay(): void + protected function addRussiaDay(): void { if ($this->year < self::RUSSIA_DAY_START_YEAR) { return; @@ -165,7 +167,7 @@ private function addRussiaDay(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function addUnityDay(): void + protected function addUnityDay(): void { if ($this->year < self::UNITY_DAY_START_YEAR) { return; diff --git a/src/Yasumi/Provider/Slovakia.php b/src/Yasumi/Provider/Slovakia.php index 12f625531..f6b0474d0 100644 --- a/src/Yasumi/Provider/Slovakia.php +++ b/src/Yasumi/Provider/Slovakia.php @@ -1,9 +1,11 @@ calculateSaintsCyrilAndMethodiusDay(); // 29.8. $this->calculateSlovakNationalUprisingDay(); - // 1.9. + // 1.9.(<2024) $this->calculateSlovakConstitutionDay(); // 15.9. $this->calculateOurLadyOfSorrowsDay(); + // 30.10.2018 + $this->calculateDeclarationOfTheSlovakNation(); // 1.11. $this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale, Holiday::TYPE_BANK)); // 17.11. @@ -112,6 +116,31 @@ public function getSources(): array ]; } + /** + * Anniversary of the Declaration of the Slovak Nation. + * In 2018, October 30 was a one-time public holiday. For this reason, it was not a commemorative day in 2018. + * + * @see https://sk.wikipedia.org/wiki/Zoznam_sviatkov_na_Slovensku#endnote_pozn-01 + * + * @throws \InvalidArgumentException + * @throws UnknownLocaleException + * @throws \Exception + */ + protected function calculateDeclarationOfTheSlovakNation(): void + { + if (2018 === $this->year) { + $this->addHoliday(new Holiday( + 'declarationOfTheSlovakNation', + [ + 'sk' => 'Výročie Deklarácie slovenského národa', + 'en' => 'Anniversary of the Declaration of the Slovak Nation', + ], + new \DateTime($this->year . '-10-30', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + $this->locale + )); + } + } + /** * New Year's Day. * @@ -121,7 +150,7 @@ public function getSources(): array * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSlovakIndependenceDay(): void + protected function calculateSlovakIndependenceDay(): void { $this->addHoliday(new Holiday( 'slovakIndependenceDay', @@ -129,7 +158,7 @@ private function calculateSlovakIndependenceDay(): void 'sk' => 'Deň vzniku Slovenskej republiky', 'en' => 'Day of the Establishment of the Slovak Republic', ], - new \DateTime($this->year.'-01-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-01-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale )); } @@ -145,7 +174,7 @@ private function calculateSlovakIndependenceDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSaintsCyrilAndMethodiusDay(): void + protected function calculateSaintsCyrilAndMethodiusDay(): void { $this->addHoliday(new Holiday( 'saintsCyrilAndMethodiusDay', @@ -154,7 +183,7 @@ private function calculateSaintsCyrilAndMethodiusDay(): void 'cs' => 'Den slovanských věrozvěstů Cyrila a Metoděje', 'en' => 'Saints Cyril and Methodius Day', ], - new \DateTime($this->year.'-07-05', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-07-05', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); @@ -169,7 +198,7 @@ private function calculateSaintsCyrilAndMethodiusDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSlovakNationalUprisingDay(): void + protected function calculateSlovakNationalUprisingDay(): void { $this->addHoliday(new Holiday( 'slovakNationalUprisingDay', @@ -177,7 +206,7 @@ private function calculateSlovakNationalUprisingDay(): void 'sk' => 'Výročie Slovenského národného povstania', 'en' => 'Slovak National Uprising Day', ], - new \DateTime($this->year.'-08-29', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-08-29', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); @@ -187,23 +216,27 @@ private function calculateSlovakNationalUprisingDay(): void * Day of the Constitution of the Slovak Republic. * * @see https://en.wikipedia.org/wiki/Constitution_of_Slovakia + * Removed since 2024 + * @see https://www.slov-lex.sk/pravne-predpisy/SK/ZZ/1993/241/ * * @throws \InvalidArgumentException * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSlovakConstitutionDay(): void + protected function calculateSlovakConstitutionDay(): void { - $this->addHoliday(new Holiday( - 'slovakConstitutionDay', - [ - 'sk' => 'Deň Ústavy Slovenskej republiky', - 'en' => 'Day of the Constitution of the Slovak Republic', - ], - new \DateTime($this->year.'-09-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)), - $this->locale, - Holiday::TYPE_OFFICIAL - )); + if ($this->year < 2024) { + $this->addHoliday(new Holiday( + 'slovakConstitutionDay', + [ + 'sk' => 'Deň Ústavy Slovenskej republiky', + 'en' => 'Day of the Constitution of the Slovak Republic', + ], + new \DateTime($this->year . '-09-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + $this->locale, + Holiday::TYPE_OFFICIAL + )); + } } /** @@ -219,12 +252,12 @@ private function calculateSlovakConstitutionDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateOurLadyOfSorrowsDay(): void + protected function calculateOurLadyOfSorrowsDay(): void { $this->addHoliday(new Holiday('ourLadyOfSorrowsDay', [ 'sk' => 'Sviatok Sedembolestnej Panny Márie', 'en' => 'Our Lady of Sorrows Day', - ], new \DateTime($this->year.'-09-15', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_BANK)); + ], new \DateTime($this->year . '-09-15', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_BANK)); } /** @@ -236,7 +269,7 @@ private function calculateOurLadyOfSorrowsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateStruggleForFreedomAndDemocracyDay(): void + protected function calculateStruggleForFreedomAndDemocracyDay(): void { $this->addHoliday(new Holiday( 'struggleForFreedomAndDemocracyDay', @@ -245,7 +278,7 @@ private function calculateStruggleForFreedomAndDemocracyDay(): void 'cs' => 'Den boje za svobodu a demokracii', 'en' => 'Struggle for Freedom and Democracy Day', ], - new \DateTime($this->year.'-11-17', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-11-17', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); diff --git a/src/Yasumi/Provider/SouthAfrica.php b/src/Yasumi/Provider/SouthAfrica.php index 792af587f..5ce3d446c 100644 --- a/src/Yasumi/Provider/SouthAfrica.php +++ b/src/Yasumi/Provider/SouthAfrica.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'humanRightsDay', ['en' => 'Human Rights Day'], - new \DateTime($this->year.'-3-21', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-3-21', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale )); } @@ -122,7 +124,7 @@ private function calculateHumanRightsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateFamilyDay(): void + protected function calculateFamilyDay(): void { $this->addHoliday(new Holiday( 'familyDay', @@ -144,12 +146,12 @@ private function calculateFamilyDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateFreedomDay(): void + protected function calculateFreedomDay(): void { $this->addHoliday(new Holiday( 'freedomDay', ['en' => 'Freedom Day'], - new \DateTime($this->year.'-4-27', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-4-27', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale )); } @@ -170,12 +172,12 @@ private function calculateFreedomDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateYouthDay(): void + protected function calculateYouthDay(): void { $this->addHoliday(new Holiday( 'youthDay', ['en' => 'Youth Day'], - new \DateTime($this->year.'-6-16', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-6-16', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale )); } @@ -192,7 +194,7 @@ private function calculateYouthDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculate2016MunicipalElectionsDay(): void + protected function calculate2016MunicipalElectionsDay(): void { if (2016 !== $this->year) { return; @@ -220,12 +222,12 @@ private function calculate2016MunicipalElectionsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateNationalWomensDay(): void + protected function calculateNationalWomensDay(): void { $this->addHoliday(new Holiday( 'nationalWomensDay', ['en' => 'National Women’s Day'], - new \DateTime($this->year.'-8-9', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-8-9', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale )); } @@ -244,12 +246,12 @@ private function calculateNationalWomensDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateHeritageDay(): void + protected function calculateHeritageDay(): void { $this->addHoliday(new Holiday( 'heritageDay', ['en' => 'Heritage Day'], - new \DateTime($this->year.'-9-24', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-9-24', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale )); } @@ -270,12 +272,12 @@ private function calculateHeritageDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateDayOfReconciliation(): void + protected function calculateDayOfReconciliation(): void { $this->addHoliday(new Holiday( 'reconciliationDay', ['en' => 'Day of Reconciliation'], - new \DateTime($this->year.'-12-16', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-12-16', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale )); } @@ -295,7 +297,7 @@ private function calculateDayOfReconciliation(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSubstituteDayOfGoodwill(): void + protected function calculateSubstituteDayOfGoodwill(): void { if (2016 !== $this->year) { return; @@ -319,7 +321,7 @@ private function calculateSubstituteDayOfGoodwill(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSubstituteHolidays(): void + protected function calculateSubstituteHolidays(): void { // Loop through all defined holidays foreach ($this->getHolidays() as $holiday) { diff --git a/src/Yasumi/Provider/SouthKorea.php b/src/Yasumi/Provider/SouthKorea.php index 34f5b8280..c32ac9084 100644 --- a/src/Yasumi/Provider/SouthKorea.php +++ b/src/Yasumi/Provider/SouthKorea.php @@ -1,9 +1,11 @@ list of holidays */ - private function calculateBefore2013(int $year): array + protected function calculateBefore2013(int $year): array { $officialHolidays = []; @@ -797,7 +799,7 @@ private function calculateBefore2013(int $year): array * * @return array list of holidays */ - private function calculateCurrent(): array + protected function calculateCurrent(): array { return [ 'newYearsDay', @@ -832,7 +834,7 @@ private function calculateCurrent(): array * * @throws \Exception */ - private function calculateOldSubstituteHolidays(int $year): void + protected function calculateOldSubstituteHolidays(int $year): void { // Add substitute holidays by fixed entries. switch ($year) { @@ -891,7 +893,7 @@ private function calculateOldSubstituteHolidays(int $year): void * * @throws \Exception */ - private function calculateSubstituteHolidays(int $year): void + protected function calculateSubstituteHolidays(int $year): void { if ($year < 2023) { $this->calculateOldSubstituteHolidays($year); @@ -918,7 +920,7 @@ private function calculateSubstituteHolidays(int $year): void $dayOfWeek = (int) $holiday->format('w'); if (\in_array($dayOfWeek, $acceptedHolidays[$name], true)) { - $dates[$day]['weekend:'.$day] = $name; + $dates[$day]['weekend:' . $day] = $name; } } @@ -949,7 +951,7 @@ private function calculateSubstituteHolidays(int $year): void * * @return array> */ - private function calculateAcceptedSubstituteHolidays(int $year): array + protected function calculateAcceptedSubstituteHolidays(int $year): array { // List of holidays allowed for substitution. // This dictionary has key => value mappings. @@ -981,7 +983,7 @@ private function calculateAcceptedSubstituteHolidays(int $year): array /** * Helper method to find a first working day after specific date. */ - private function nextWorkingDay(\DateTime $date): \DateTime + protected function nextWorkingDay(\DateTime $date): \DateTime { $interval = new \DateInterval('P1D'); $next = clone $date; @@ -999,7 +1001,7 @@ private function nextWorkingDay(\DateTime $date): \DateTime * * @throws \Exception */ - private function addSubstituteHoliday(?Holiday $origin, string $date_str): void + protected function addSubstituteHoliday(?Holiday $origin, string $date_str): void { if (! $origin instanceof Holiday) { return; diff --git a/src/Yasumi/Provider/Spain.php b/src/Yasumi/Provider/Spain.php index 9fcf2d270..2a1007d17 100644 --- a/src/Yasumi/Provider/Spain.php +++ b/src/Yasumi/Provider/Spain.php @@ -1,9 +1,11 @@ year >= 1981) { $this->addHoliday(new Holiday( @@ -112,7 +114,7 @@ private function calculateNationalDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateConstitutionDay(): void + protected function calculateConstitutionDay(): void { if ($this->year >= 1978) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/Andalusia.php b/src/Yasumi/Provider/Spain/Andalusia.php index 94af4cb13..6afa4c639 100644 --- a/src/Yasumi/Provider/Spain/Andalusia.php +++ b/src/Yasumi/Provider/Spain/Andalusia.php @@ -1,8 +1,11 @@ year >= 1980) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/Aragon.php b/src/Yasumi/Provider/Spain/Aragon.php index 5485b135e..fee3eefce 100644 --- a/src/Yasumi/Provider/Spain/Aragon.php +++ b/src/Yasumi/Provider/Spain/Aragon.php @@ -1,8 +1,11 @@ year >= 1984) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/BalearicIslands.php b/src/Yasumi/Provider/Spain/BalearicIslands.php index 05f6809c1..3fe68625d 100644 --- a/src/Yasumi/Provider/Spain/BalearicIslands.php +++ b/src/Yasumi/Provider/Spain/BalearicIslands.php @@ -1,8 +1,11 @@ year >= 1983) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/BasqueCountry.php b/src/Yasumi/Provider/Spain/BasqueCountry.php index a75e88412..133041ab1 100644 --- a/src/Yasumi/Provider/Spain/BasqueCountry.php +++ b/src/Yasumi/Provider/Spain/BasqueCountry.php @@ -1,8 +1,11 @@ year < 2011) { return; diff --git a/src/Yasumi/Provider/Spain/CanaryIslands.php b/src/Yasumi/Provider/Spain/CanaryIslands.php index aa800299a..827c51053 100644 --- a/src/Yasumi/Provider/Spain/CanaryIslands.php +++ b/src/Yasumi/Provider/Spain/CanaryIslands.php @@ -1,8 +1,11 @@ year >= 1984) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/Cantabria.php b/src/Yasumi/Provider/Spain/Cantabria.php index 0baa7dc34..1eee3253e 100644 --- a/src/Yasumi/Provider/Spain/Cantabria.php +++ b/src/Yasumi/Provider/Spain/Cantabria.php @@ -1,8 +1,11 @@ year >= 1967) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/CastileAndLeon.php b/src/Yasumi/Provider/Spain/CastileAndLeon.php index 75326dacb..579f722d9 100644 --- a/src/Yasumi/Provider/Spain/CastileAndLeon.php +++ b/src/Yasumi/Provider/Spain/CastileAndLeon.php @@ -1,9 +1,11 @@ year >= 1976) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/CastillaLaMancha.php b/src/Yasumi/Provider/Spain/CastillaLaMancha.php index cc80a91ee..30908e408 100644 --- a/src/Yasumi/Provider/Spain/CastillaLaMancha.php +++ b/src/Yasumi/Provider/Spain/CastillaLaMancha.php @@ -1,9 +1,11 @@ year >= 1984) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/Catalonia.php b/src/Yasumi/Provider/Spain/Catalonia.php index 285a3b431..2ed356d68 100644 --- a/src/Yasumi/Provider/Spain/Catalonia.php +++ b/src/Yasumi/Provider/Spain/Catalonia.php @@ -1,8 +1,11 @@ year >= 1886) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/Ceuta.php b/src/Yasumi/Provider/Spain/Ceuta.php index 227c1be29..244eeadfb 100644 --- a/src/Yasumi/Provider/Spain/Ceuta.php +++ b/src/Yasumi/Provider/Spain/Ceuta.php @@ -1,8 +1,11 @@ year >= 1416) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/CommunityOfMadrid.php b/src/Yasumi/Provider/Spain/CommunityOfMadrid.php index 94bdf57fa..c85dd38e3 100644 --- a/src/Yasumi/Provider/Spain/CommunityOfMadrid.php +++ b/src/Yasumi/Provider/Spain/CommunityOfMadrid.php @@ -1,8 +1,11 @@ addHoliday(new Holiday( 'dosdeMayoUprisingDay', diff --git a/src/Yasumi/Provider/Spain/Extremadura.php b/src/Yasumi/Provider/Spain/Extremadura.php index d877ee629..55c81db05 100644 --- a/src/Yasumi/Provider/Spain/Extremadura.php +++ b/src/Yasumi/Provider/Spain/Extremadura.php @@ -1,8 +1,11 @@ year >= 1985) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Spain/Galicia.php b/src/Yasumi/Provider/Spain/Galicia.php index 4b4d9d3c8..76edf33ab 100644 --- a/src/Yasumi/Provider/Spain/Galicia.php +++ b/src/Yasumi/Provider/Spain/Galicia.php @@ -1,8 +1,11 @@ year >= 1991) { $this->addHoliday(new Holiday('galicianLiteratureDay', [ @@ -101,7 +104,7 @@ private function calculateGalicianLiteratureDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateStJamesDay(): void + protected function calculateStJamesDay(): void { if ($this->year >= 2000) { $this->addHoliday(new Holiday('stJamesDay', [ diff --git a/src/Yasumi/Provider/Spain/LaRioja.php b/src/Yasumi/Provider/Spain/LaRioja.php index 5fe8b01c9..3c362f831 100644 --- a/src/Yasumi/Provider/Spain/LaRioja.php +++ b/src/Yasumi/Provider/Spain/LaRioja.php @@ -1,8 +1,11 @@ year >= 1983) { $this->addHoliday(new Holiday('laRiojaDay', [ diff --git a/src/Yasumi/Provider/Spain/Melilla.php b/src/Yasumi/Provider/Spain/Melilla.php index 1592819b4..e25e4d391 100644 --- a/src/Yasumi/Provider/Spain/Melilla.php +++ b/src/Yasumi/Provider/Spain/Melilla.php @@ -1,8 +1,11 @@ year >= 1983) { $this->addHoliday(new Holiday('murciaDay', [ diff --git a/src/Yasumi/Provider/Spain/ValencianCommunity.php b/src/Yasumi/Provider/Spain/ValencianCommunity.php index 116644721..63cf6eab4 100644 --- a/src/Yasumi/Provider/Spain/ValencianCommunity.php +++ b/src/Yasumi/Provider/Spain/ValencianCommunity.php @@ -1,8 +1,11 @@ year >= 1239) { $this->addHoliday(new Holiday( diff --git a/src/Yasumi/Provider/Sweden.php b/src/Yasumi/Provider/Sweden.php index 8d2c62f56..818028b84 100644 --- a/src/Yasumi/Provider/Sweden.php +++ b/src/Yasumi/Provider/Sweden.php @@ -1,9 +1,11 @@ addHoliday(new Holiday( 'epiphanyEve', @@ -117,7 +119,7 @@ private function calculateEpiphanyEve(): void * @throws \InvalidArgumentException * @throws \Exception */ - private function calculateWalpurgisEve(): void + protected function calculateWalpurgisEve(): void { $this->addHoliday(new Holiday( 'walpurgisEve', @@ -146,7 +148,7 @@ private function calculateWalpurgisEve(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateStJohnsHolidays(): void + protected function calculateStJohnsHolidays(): void { $date = new \DateTime("{$this->year}-6-20 this saturday", DateTimeZoneFactory::getDateTimeZone($this->timezone)); $this->addHoliday(new Holiday( @@ -186,7 +188,7 @@ private function calculateStJohnsHolidays(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateAllSaintsHolidays(): void + protected function calculateAllSaintsHolidays(): void { $date = new \DateTime("{$this->year}-10-31 this saturday", DateTimeZoneFactory::getDateTimeZone($this->timezone)); $this->addHoliday(new Holiday( @@ -219,7 +221,7 @@ private function calculateAllSaintsHolidays(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateNationalDay(): void + protected function calculateNationalDay(): void { if ($this->year < 1916) { return; diff --git a/src/Yasumi/Provider/Switzerland.php b/src/Yasumi/Provider/Switzerland.php index a10be9c7c..808fa5b51 100644 --- a/src/Yasumi/Provider/Switzerland.php +++ b/src/Yasumi/Provider/Switzerland.php @@ -1,9 +1,11 @@ 'Jour de la Saint-Berthold', 'en' => 'Berchtoldstag', ], - new \DateTime($this->year.'-01-02', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-01-02', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OTHER )); @@ -101,7 +103,7 @@ protected function calculateBettagsMontag(): void { if ($this->year >= 1832) { // Find third Sunday of September - $date = new \DateTime('Third Sunday of '.$this->year.'-09', DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime('Third Sunday of ' . $this->year . '-09', DateTimeZoneFactory::getDateTimeZone($this->timezone)); // Go to next Thursday $date->add(new \DateInterval('P1D')); @@ -126,7 +128,7 @@ protected function calculateBettagsMontag(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateNationalDay(): void + protected function calculateNationalDay(): void { $translations = [ 'en' => 'National Day', @@ -139,7 +141,7 @@ private function calculateNationalDay(): void $this->addHoliday(new Holiday( 'swissNationalDay', $translations, - new \DateTime($this->year.'-08-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-08-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OFFICIAL )); @@ -147,7 +149,7 @@ private function calculateNationalDay(): void $this->addHoliday(new Holiday( 'swissNationalDay', $translations, - new \DateTime($this->year.'-08-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-08-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OBSERVANCE )); diff --git a/src/Yasumi/Provider/Switzerland/Aargau.php b/src/Yasumi/Provider/Switzerland/Aargau.php index 00a46c444..419415503 100644 --- a/src/Yasumi/Provider/Switzerland/Aargau.php +++ b/src/Yasumi/Provider/Switzerland/Aargau.php @@ -1,8 +1,11 @@ addHoliday(new Holiday( 'december26th', @@ -81,7 +84,7 @@ private function calculateDecember26th(): void 'en' => 'December 26th', 'fr' => '26 décembre', ], - new \DateTime($this->year.'-12-26', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-12-26', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OTHER )); diff --git a/src/Yasumi/Provider/Switzerland/Geneva.php b/src/Yasumi/Provider/Switzerland/Geneva.php index aaa621319..d09489768 100644 --- a/src/Yasumi/Provider/Switzerland/Geneva.php +++ b/src/Yasumi/Provider/Switzerland/Geneva.php @@ -1,8 +1,11 @@ $this->year) { return; } // Find first Sunday of September - $date = new \DateTime('First Sunday of '.$this->year.'-09', DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime('First Sunday of ' . $this->year . '-09', DateTimeZoneFactory::getDateTimeZone($this->timezone)); // Go to next Thursday $date->add(new \DateInterval('P4D')); @@ -107,7 +110,7 @@ private function calculateJeuneGenevois(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateRestaurationGenevoise(): void + protected function calculateRestaurationGenevoise(): void { if ($this->year > 1813) { $this->addHoliday(new Holiday( @@ -115,7 +118,7 @@ private function calculateRestaurationGenevoise(): void [ 'fr' => 'Restauration de la République', ], - new \DateTime($this->year.'-12-31', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-12-31', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OTHER )); diff --git a/src/Yasumi/Provider/Switzerland/Glarus.php b/src/Yasumi/Provider/Switzerland/Glarus.php index 1f07bfde8..2f81a2495 100644 --- a/src/Yasumi/Provider/Switzerland/Glarus.php +++ b/src/Yasumi/Provider/Switzerland/Glarus.php @@ -1,8 +1,11 @@ year >= 1389) { - $date = new \DateTime('First Thursday of '.$this->year.'-04', DateTimeZoneFactory::getDateTimeZone($this->timezone)); + $date = new \DateTime('First Thursday of ' . $this->year . '-04', DateTimeZoneFactory::getDateTimeZone($this->timezone)); $this->addHoliday(new Holiday('nafelserFahrt', [ 'de' => 'Näfelser Fahrt', ], $date, $this->locale, Holiday::TYPE_OTHER)); diff --git a/src/Yasumi/Provider/Switzerland/Grisons.php b/src/Yasumi/Provider/Switzerland/Grisons.php index 36ffbeb69..6c33268fb 100644 --- a/src/Yasumi/Provider/Switzerland/Grisons.php +++ b/src/Yasumi/Provider/Switzerland/Grisons.php @@ -1,8 +1,11 @@ year > 1974) { $this->addHoliday(new Holiday( @@ -87,7 +90,7 @@ private function calculatePlebisciteJurassien(): void [ 'fr' => 'Commémoration du plébiscite jurassien', ], - new \DateTime($this->year.'-06-23', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-06-23', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OTHER )); diff --git a/src/Yasumi/Provider/Switzerland/Lucerne.php b/src/Yasumi/Provider/Switzerland/Lucerne.php index 30352ca47..a2ae96b48 100644 --- a/src/Yasumi/Provider/Switzerland/Lucerne.php +++ b/src/Yasumi/Provider/Switzerland/Lucerne.php @@ -1,8 +1,11 @@ year > 1848) { $this->addHoliday(new Holiday( @@ -94,7 +97,7 @@ private function calculateInstaurationRepublique(): void [ 'fr' => 'Instauration de la République', ], - new \DateTime($this->year.'-03-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-03-01', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OTHER )); @@ -108,7 +111,7 @@ private function calculateInstaurationRepublique(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateJanuary2nd(): void + protected function calculateJanuary2nd(): void { $this->addHoliday(new Holiday( 'january2nd', @@ -116,7 +119,7 @@ private function calculateJanuary2nd(): void 'en' => 'January 2nd', 'fr' => '2 janvier', ], - new \DateTime($this->year.'-01-02', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-01-02', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OTHER )); @@ -129,7 +132,7 @@ private function calculateJanuary2nd(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateDecember26th(): void + protected function calculateDecember26th(): void { $this->addHoliday(new Holiday( 'december26th', @@ -137,7 +140,7 @@ private function calculateDecember26th(): void 'en' => 'December 26th', 'fr' => '26 décembre', ], - new \DateTime($this->year.'-12-26', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-12-26', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OTHER )); diff --git a/src/Yasumi/Provider/Switzerland/Nidwalden.php b/src/Yasumi/Provider/Switzerland/Nidwalden.php index 0d0a42a73..d147fcce3 100644 --- a/src/Yasumi/Provider/Switzerland/Nidwalden.php +++ b/src/Yasumi/Provider/Switzerland/Nidwalden.php @@ -1,8 +1,11 @@ year >= 1947) { $this->addHoliday(new Holiday( @@ -84,7 +87,7 @@ private function calculateBruderKlausenFest(): void [ 'de' => 'Bruder-Klausen-Fest', ], - new \DateTime($this->year.'-09-25', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-09-25', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OTHER )); @@ -94,7 +97,7 @@ private function calculateBruderKlausenFest(): void [ 'de' => 'Bruder-Klausen-Fest', ], - new \DateTime($this->year.'-09-21', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-09-21', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OTHER )); diff --git a/src/Yasumi/Provider/Switzerland/Schaffhausen.php b/src/Yasumi/Provider/Switzerland/Schaffhausen.php index c15f4f638..0ffcc885c 100644 --- a/src/Yasumi/Provider/Switzerland/Schaffhausen.php +++ b/src/Yasumi/Provider/Switzerland/Schaffhausen.php @@ -1,8 +1,11 @@ addHoliday(new Holiday( 'stPeterPaul', @@ -92,7 +95,7 @@ private function calculateStPeterPaul(): void 'fr' => 'Solennité des saints Pierre et Paul', 'de' => 'St. Peter und Paul', ], - new \DateTime($this->year.'-06-29', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-06-29', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_OTHER )); diff --git a/src/Yasumi/Provider/Switzerland/Uri.php b/src/Yasumi/Provider/Switzerland/Uri.php index 49358abc6..2b6f630e6 100644 --- a/src/Yasumi/Provider/Switzerland/Uri.php +++ b/src/Yasumi/Provider/Switzerland/Uri.php @@ -1,8 +1,11 @@ addHoliday(new Holiday('labourDay', [ 'tr' => 'Emek ve Dayanışma Günü', @@ -77,7 +79,7 @@ private function addLabourDay(): void * * @throws \Exception */ - private function addCommemorationOfAtaturk(): void + protected function addCommemorationOfAtaturk(): void { if (1920 > $this->year) { return; @@ -97,7 +99,7 @@ private function addCommemorationOfAtaturk(): void * * @throws \Exception */ - private function addNationalSovereigntyDay(): void + protected function addNationalSovereigntyDay(): void { if (1922 > $this->year) { return; @@ -123,7 +125,7 @@ private function addNationalSovereigntyDay(): void * * @throws \Exception */ - private function addDemocracyDay(): void + protected function addDemocracyDay(): void { if (2017 > $this->year) { return; @@ -142,7 +144,7 @@ private function addDemocracyDay(): void * * @throws \Exception */ - private function addVictoryDay(): void + protected function addVictoryDay(): void { if (1923 > $this->year) { return; @@ -172,7 +174,7 @@ private function addVictoryDay(): void * * @throws \Exception */ - private function addRepublicDay(): void + protected function addRepublicDay(): void { if (1924 > $this->year) { return; diff --git a/src/Yasumi/Provider/USA.php b/src/Yasumi/Provider/USA.php index d0255e145..3915c8147 100644 --- a/src/Yasumi/Provider/USA.php +++ b/src/Yasumi/Provider/USA.php @@ -1,9 +1,11 @@ year >= 1986) { $this->addHoliday(new Holiday('martinLutherKingDay', [ @@ -105,7 +107,7 @@ private function calculateMartinLutherKingday(): void * * @throws \Exception */ - private function calculateWashingtonsBirthday(): void + protected function calculateWashingtonsBirthday(): void { if ($this->year >= 1879) { $date = new \DateTime("{$this->year}-2-22", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -130,7 +132,7 @@ private function calculateWashingtonsBirthday(): void * * @throws \Exception */ - private function calculateMemorialDay(): void + protected function calculateMemorialDay(): void { if ($this->year >= 1865) { $date = new \DateTime("{$this->year}-5-30", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -155,7 +157,7 @@ private function calculateMemorialDay(): void * * @throws \Exception */ - private function calculateJuneteenth(): void + protected function calculateJuneteenth(): void { if ($this->year >= 2021) { $date = new \DateTime("{$this->year}-6-19", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -179,7 +181,7 @@ private function calculateJuneteenth(): void $this->addHoliday(new SubstituteHoliday( $holiday, [ - 'en' => $label.' (observed)', + 'en' => $label . ' (observed)', ], $date, $this->locale @@ -200,7 +202,7 @@ private function calculateJuneteenth(): void * * @throws \Exception */ - private function calculateIndependenceDay(): void + protected function calculateIndependenceDay(): void { if ($this->year >= 1776) { $this->addHoliday(new Holiday('independenceDay', [ @@ -219,7 +221,7 @@ private function calculateIndependenceDay(): void * * @throws \Exception */ - private function calculateLabourDay(): void + protected function calculateLabourDay(): void { if ($this->year >= 1887) { $this->addHoliday(new Holiday( @@ -246,7 +248,7 @@ private function calculateLabourDay(): void * * @throws \Exception */ - private function calculateColumbusDay(): void + protected function calculateColumbusDay(): void { if ($this->year >= 1937) { $date = new \DateTime("{$this->year}-10-12", DateTimeZoneFactory::getDateTimeZone($this->timezone)); @@ -270,7 +272,7 @@ private function calculateColumbusDay(): void * * @throws \Exception */ - private function calculateVeteransDay(): void + protected function calculateVeteransDay(): void { if ($this->year >= 1919) { $name = $this->year < 1954 ? 'Armistice Day' : 'Veterans Day'; @@ -293,7 +295,7 @@ private function calculateVeteransDay(): void * * @throws \Exception */ - private function calculateThanksgivingDay(): void + protected function calculateThanksgivingDay(): void { if ($this->year >= 1863) { $this->addHoliday(new Holiday( @@ -317,7 +319,7 @@ private function calculateThanksgivingDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSubstituteHolidays(): void + protected function calculateSubstituteHolidays(): void { // Loop through all defined holidays foreach ($this->getHolidays() as $holiday) { diff --git a/src/Yasumi/Provider/Ukraine.php b/src/Yasumi/Provider/Ukraine.php index 72caaf448..a98381e44 100644 --- a/src/Yasumi/Provider/Ukraine.php +++ b/src/Yasumi/Provider/Ukraine.php @@ -1,9 +1,11 @@ timezone = 'Europe/Kiev'; + // the name of the timezone changed at some point and some systems support both names, + // while others only support the old or the new one -> try out, which version is actually working + try { + new \DateTimeZone('Europe/Kyiv'); + $this->timezone = 'Europe/Kyiv'; + } catch (\Exception $e) { // @phpstan-ignore-line + // DateInvalidTimeZoneException since 8.3 + $this->timezone = 'Europe/Kiev'; + } // Add common holidays // New Years Day will not be substituted to an monday if it's on a weekend! @@ -127,7 +137,7 @@ protected function calculateEaster(int $year, string $timezone): \DateTimeInterf * @throws UnknownLocaleException * @throws \Exception */ - private function calculateChristmasDay(): void + protected function calculateChristmasDay(): void { $this->addHoliday(new Holiday( 'christmasDay', @@ -147,7 +157,7 @@ private function calculateChristmasDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSecondInternationalWorkersDay(): void + protected function calculateSecondInternationalWorkersDay(): void { if ($this->year >= 2018) { return; @@ -174,7 +184,7 @@ private function calculateSecondInternationalWorkersDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateVictoryDay(): void + protected function calculateVictoryDay(): void { $this->addHoliday(new Holiday( 'victoryDay', @@ -195,7 +205,7 @@ private function calculateVictoryDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateConstitutionDay(): void + protected function calculateConstitutionDay(): void { if ($this->year < 1996) { return; @@ -222,7 +232,7 @@ private function calculateConstitutionDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateIndependenceDay(): void + protected function calculateIndependenceDay(): void { if ($this->year < 1991) { return; @@ -250,7 +260,7 @@ private function calculateIndependenceDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateDefenderOfUkraineDay(): void + protected function calculateDefenderOfUkraineDay(): void { if ($this->year < 2015) { return; @@ -274,7 +284,7 @@ private function calculateDefenderOfUkraineDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateCatholicChristmasDay(): void + protected function calculateCatholicChristmasDay(): void { if ($this->year < 2017) { return; diff --git a/src/Yasumi/Provider/UnitedKingdom.php b/src/Yasumi/Provider/UnitedKingdom.php index 223751e06..19b2e263a 100644 --- a/src/Yasumi/Provider/UnitedKingdom.php +++ b/src/Yasumi/Provider/UnitedKingdom.php @@ -1,9 +1,11 @@ year < 1871) { @@ -358,7 +360,7 @@ private function calculateNewYearsDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateSummerBankHoliday(): void + protected function calculateSummerBankHoliday(): void { if ($this->year < 1871) { return; @@ -409,7 +411,7 @@ private function calculateSummerBankHoliday(): void * * @throws \Exception */ - private function calculateMotheringSunday(): void + protected function calculateMotheringSunday(): void { $date = $this->calculateEaster($this->year, $this->timezone); $date->sub(new \DateInterval('P3W')); diff --git a/src/Yasumi/Provider/UnitedKingdom/England.php b/src/Yasumi/Provider/UnitedKingdom/England.php index b16e05601..e9f22b1cb 100644 --- a/src/Yasumi/Provider/UnitedKingdom/England.php +++ b/src/Yasumi/Provider/UnitedKingdom/England.php @@ -1,8 +1,11 @@ year < 1971) { return; @@ -76,7 +79,7 @@ private function calculateStPatricksDay(): void $holiday = new Holiday( 'stPatricksDay', ['en' => 'St. Patrick’s Day'], - new \DateTime($this->year.'-3-17', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-3-17', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_BANK ); @@ -111,7 +114,7 @@ private function calculateStPatricksDay(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateBattleOfTheBoyne(): void + protected function calculateBattleOfTheBoyne(): void { if ($this->year < 1926) { return; @@ -120,7 +123,7 @@ private function calculateBattleOfTheBoyne(): void $holiday = new Holiday( 'battleOfTheBoyne', ['en' => 'Battle of the Boyne'], - new \DateTime($this->year.'-7-12', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-7-12', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_BANK ); diff --git a/src/Yasumi/Provider/UnitedKingdom/Scotland.php b/src/Yasumi/Provider/UnitedKingdom/Scotland.php index 2668258eb..e0b14b02f 100644 --- a/src/Yasumi/Provider/UnitedKingdom/Scotland.php +++ b/src/Yasumi/Provider/UnitedKingdom/Scotland.php @@ -1,8 +1,11 @@ year < 1871) { return; @@ -109,7 +112,7 @@ private function calculateSummerBankHoliday(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateNewYearsHolidays(): void + protected function calculateNewYearsHolidays(): void { // Before 1871 it was not an observed or statutory holiday if ($this->year < 1871) { @@ -169,7 +172,7 @@ private function calculateNewYearsHolidays(): void * @throws UnknownLocaleException * @throws \Exception */ - private function calculateStAndrewsDay(): void + protected function calculateStAndrewsDay(): void { if ($this->year < 2007) { return; @@ -177,7 +180,7 @@ private function calculateStAndrewsDay(): void $holiday = new Holiday( 'stAndrewsDay', [], - new \DateTime($this->year.'-11-30', DateTimeZoneFactory::getDateTimeZone($this->timezone)), + new \DateTime($this->year . '-11-30', DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale, Holiday::TYPE_BANK ); diff --git a/src/Yasumi/Provider/UnitedKingdom/Wales.php b/src/Yasumi/Provider/UnitedKingdom/Wales.php index 21a6bc1f9..a59defc64 100644 --- a/src/Yasumi/Provider/UnitedKingdom/Wales.php +++ b/src/Yasumi/Provider/UnitedKingdom/Wales.php @@ -1,8 +1,11 @@ substitutedHoliday = $substitutedHoliday; - $key = 'substituteHoliday:'.$substitutedHoliday->getKey(); + $key = 'substituteHoliday:' . $substitutedHoliday->getKey(); if ($date == $substitutedHoliday) { throw new \InvalidArgumentException('Date must differ from the substituted holiday'); diff --git a/src/Yasumi/Translations.php b/src/Yasumi/Translations.php index 7d1f93ca8..e7ec9a248 100644 --- a/src/Yasumi/Translations.php +++ b/src/Yasumi/Translations.php @@ -1,9 +1,11 @@ getFilename(); - $key = $file->getBasename('.'.$extension); + $key = $file->getBasename('.' . $extension); - $translations = require $directoryPath.$filename; + $translations = require $directoryPath . $filename; if (\is_array($translations)) { foreach (array_keys($translations) as $locale) { diff --git a/src/Yasumi/TranslationsInterface.php b/src/Yasumi/TranslationsInterface.php index 717d848fd..4adfe4b50 100644 --- a/src/Yasumi/TranslationsInterface.php +++ b/src/Yasumi/TranslationsInterface.php @@ -1,9 +1,11 @@ loadTranslations(__DIR__.'/data/translations'); + self::$globalTranslations->loadTranslations(__DIR__ . '/data/translations'); } // Assert locale input @@ -158,7 +160,7 @@ public static function create(string $class, int $year = self::YEAR_LOWER_BOUND, */ public static function getAvailableLocales(): array { - return require __DIR__.'/data/locales.php'; + return require __DIR__ . '/data/locales.php'; } /** @@ -212,7 +214,7 @@ public static function getProviders(): array $providers = []; $filesIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( - __DIR__.\DIRECTORY_SEPARATOR.'Provider', + __DIR__ . \DIRECTORY_SEPARATOR . 'Provider', \FilesystemIterator::SKIP_DOTS ), \RecursiveIteratorIterator::SELF_FIRST); diff --git a/src/Yasumi/data/locales.php b/src/Yasumi/data/locales.php index 35917a5d4..9e465b29e 100644 --- a/src/Yasumi/data/locales.php +++ b/src/Yasumi/data/locales.php @@ -1,8 +1,11 @@ between( new \DateTime('03/25/2011', new \DateTimeZone($timezone)), - new \DateTime('05/17/'.$year, new \DateTimeZone($timezone)) + new \DateTime('05/17/' . $year, new \DateTimeZone($timezone)) ); $betweenHolidays = iterator_to_array($between); @@ -232,7 +235,7 @@ public function testHolidaysBetweenDateRangeWithEndAfterInstanceYear(): void $holidays = Yasumi::create('Italy', $year); $between = $holidays->between( - new \DateTime('03/25/'.$year, new \DateTimeZone($timezone)), + new \DateTime('03/25/' . $year, new \DateTimeZone($timezone)), new \DateTime('09/21/2021', new \DateTimeZone($timezone)) ); @@ -269,8 +272,8 @@ public function testWrongDates(): void $holidays = Yasumi::create('USA', $year); $holidays->between( - new \DateTime('12/31/'.$year, new \DateTimeZone($timezone)), - new \DateTime('01/01/'.$year, new \DateTimeZone($timezone)) + new \DateTime('12/31/' . $year, new \DateTimeZone($timezone)), + new \DateTime('01/01/' . $year, new \DateTimeZone($timezone)) ); } @@ -289,8 +292,8 @@ public function testCountBetweenWithSubstitutes(): void $holidays = Yasumi::create('Ireland', $year); $between = $holidays->between( - new \DateTime('01/01/'.$year, new \DateTimeZone($timezone)), - new \DateTime('12/31/'.$year, new \DateTimeZone($timezone)) + new \DateTime('01/01/' . $year, new \DateTimeZone($timezone)), + new \DateTime('12/31/' . $year, new \DateTimeZone($timezone)) ); $betweenHolidays = iterator_to_array($between); @@ -329,8 +332,8 @@ public function testCountBetweenExcludingSubstituteHoliday(): void $holidays = Yasumi::create('Ireland', $year); $between = $holidays->between( - new \DateTime('01/01/'.$year, new \DateTimeZone($timezone)), - new \DateTime('03/20/'.$year, new \DateTimeZone($timezone)) + new \DateTime('01/01/' . $year, new \DateTimeZone($timezone)), + new \DateTime('03/20/' . $year, new \DateTimeZone($timezone)) ); $betweenHolidays = iterator_to_array($between); @@ -373,8 +376,8 @@ public function testCountBetweenExcludingSubstituteHolidayIncludingOriginalHolid $holidays = Yasumi::create('Ireland', $year); $between = $holidays->between( - new \DateTime('01/01/'.$year, new \DateTimeZone($timezone)), - new \DateTime('03/18/'.$year, new \DateTimeZone($timezone)) + new \DateTime('01/01/' . $year, new \DateTimeZone($timezone)), + new \DateTime('03/18/' . $year, new \DateTimeZone($timezone)) ); $betweenHolidays = iterator_to_array($between); @@ -418,8 +421,8 @@ public function testCountBetweenExcludingSubstituteHolidayAndOriginalHoliday(): $holidays = Yasumi::create('Ireland', $year); $between = $holidays->between( - new \DateTime('01/01/'.$year, new \DateTimeZone($timezone)), - new \DateTime('03/16/'.$year, new \DateTimeZone($timezone)) + new \DateTime('01/01/' . $year, new \DateTimeZone($timezone)), + new \DateTime('03/16/' . $year, new \DateTimeZone($timezone)) ); $betweenHolidays = iterator_to_array($between); diff --git a/tests/Base/HolidayFiltersTest.php b/tests/Base/HolidayFiltersTest.php index 3fbcd82fa..b9ce89597 100644 --- a/tests/Base/HolidayFiltersTest.php +++ b/tests/Base/HolidayFiltersTest.php @@ -1,8 +1,11 @@ getName()); - self::assertEquals('substituteHoliday:'.$name, $substitute->getName()); + self::assertEquals('substituteHoliday:' . $name, $substitute->getName()); } /** @throws \Exception */ diff --git a/tests/Base/TranslationsTest.php b/tests/Base/TranslationsTest.php index 0ef705eab..cd3640482 100644 --- a/tests/Base/TranslationsTest.php +++ b/tests/Base/TranslationsTest.php @@ -1,8 +1,11 @@ [$key.'.php' => $fileContents]]); + vfsStream::setup('root', null, ['lang' => [$key . '.php' => $fileContents]]); $translations = new Translations(self::LOCALES); $translations->loadTranslations(vfsStream::url('root/lang')); @@ -181,7 +184,7 @@ public function testNotLoadingTranslationsFromFileWithInvalidExtension(): void ]; FILE; - vfsStream::setup('root', null, ['lang' => [$key.'.translation' => $fileContents]]); + vfsStream::setup('root', null, ['lang' => [$key . '.translation' => $fileContents]]); $translations = new Translations(self::LOCALES); $translations->loadTranslations(vfsStream::url('root/lang')); @@ -203,7 +206,7 @@ public function testLoadingTranslationsFromDirectoryWithUnknownLocaleException() ]; FILE; - vfsStream::setup('root', null, ['lang' => [$key.'.php' => $fileContents]]); + vfsStream::setup('root', null, ['lang' => [$key . '.php' => $fileContents]]); $translations = new Translations(self::LOCALES); $translations->loadTranslations(vfsStream::url('root/lang')); @@ -242,8 +245,8 @@ public function testLoadingMultipleTranslationsFromDirectory(): void vfsStream::setup('root', null, [ 'lang' => [ - $firstIdentifier.'.php' => $firstFileContents, - $secondIdentifier.'.php' => $secondFileContents, + $firstIdentifier . '.php' => $firstFileContents, + $secondIdentifier . '.php' => $secondFileContents, ], ]); diff --git a/tests/Base/TypographyTest.php b/tests/Base/TypographyTest.php index 913bdbb6d..bcf9d3321 100644 --- a/tests/Base/TypographyTest.php +++ b/tests/Base/TypographyTest.php @@ -1,9 +1,11 @@ isHoliday(new \DateTime($date)); @@ -296,7 +299,7 @@ public function testIsNotHoliday(): void { $year = 5220; $provider = 'Japan'; - $date = $year.'-06-10'; + $date = $year . '-06-10'; // Assertion using a DateTime instance $isHoliday = Yasumi::create($provider, $year)->isHoliday(new \DateTime($date)); @@ -323,7 +326,7 @@ public function testIsWorkingDay(): void { $year = 2020; $provider = 'Netherlands'; - $date = $year.'-06-02'; + $date = $year . '-06-02'; // Assertion using a DateTime instance $isWorkingDay = Yasumi::create($provider, $year)->isWorkingDay(new \DateTime($date)); @@ -350,7 +353,7 @@ public function testIsNotWorkingDay(): void { $year = 2016; $provider = 'Japan'; - $date = $year.'-01-11'; + $date = $year . '-01-11'; // Assertion using a DateTime instance $isNotWorkingDay = Yasumi::create($provider, $year)->isWorkingDay(new \DateTime($date)); diff --git a/tests/Base/YasumiWorkdayTest.php b/tests/Base/YasumiWorkdayTest.php index c4a971d5c..e83fc34b9 100644 --- a/tests/Base/YasumiWorkdayTest.php +++ b/tests/Base/YasumiWorkdayTest.php @@ -1,8 +1,11 @@ + */ namespace Yasumi\tests\Georgia; diff --git a/tests/Georgia/GeorgiaBaseTestCase.php b/tests/Georgia/GeorgiaBaseTestCase.php index 98bbcde79..aba2854b9 100644 --- a/tests/Georgia/GeorgiaBaseTestCase.php +++ b/tests/Georgia/GeorgiaBaseTestCase.php @@ -1,9 +1,11 @@ + */ + +namespace Yasumi\tests\Germany\Bavaria; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; + +/** + * Class for testing the day of the Assumption of Mary in Bavaria (Germany). + */ +class AssumptionOfMaryTest extends BavariaBaseTestCase implements HolidayTestCase +{ + /** + * The name of the holiday. + */ + public const HOLIDAY = 'assumptionOfMary'; + + /** + * Tests the holiday defined in this test. + * + * @dataProvider HolidayDataProvider + * + * @param int $year the year for which the holiday defined in this test needs to be tested + * @param \DateTime $expected the expected date + */ + public function testHoliday(int $year, \DateTimeInterface $expected): void + { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } + + /** + * Returns a list of random test dates used for assertion of the holiday defined in this test. + * + * @return array list of test dates for the holiday defined in this test + * + * @throws \Exception + */ + public function HolidayDataProvider(): array + { + return $this->generateRandomDates(8, 15, self::TIMEZONE); + } + + /** + * Tests translated name of the Assumption of Mary. + * + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [self::LOCALE => 'Mariä Himmelfahrt'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OTHER); + } +} diff --git a/tests/Germany/Bavaria/BavariaBaseTestCase.php b/tests/Germany/Bavaria/BavariaBaseTestCase.php index 16638d680..e2e5034f6 100644 --- a/tests/Germany/Bavaria/BavariaBaseTestCase.php +++ b/tests/Germany/Bavaria/BavariaBaseTestCase.php @@ -1,8 +1,11 @@ assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OTHER); + $this->assertDefinedHolidays([ + 'newYearsEve', + 'pentecost', + ], self::REGION, $this->year, Holiday::TYPE_OTHER); } /** diff --git a/tests/Germany/GoodFridayTest.php b/tests/Germany/GoodFridayTest.php index ed7d3b350..c538d5b36 100644 --- a/tests/Germany/GoodFridayTest.php +++ b/tests/Germany/GoodFridayTest.php @@ -1,8 +1,11 @@ generateRandomYear(); $time_stamp = strtotime( - $year.'-03-21'.easter_days($year).' day + 49 day' + $year . '-03-21' . easter_days($year) . ' day + 49 day' ); $date = date('Y-m-d', $time_stamp); @@ -70,6 +73,6 @@ public function testTranslation(): void */ public function testHolidayType(): void { - $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OTHER); } } diff --git a/tests/Germany/ReformationDay2017Test.php b/tests/Germany/ReformationDay2017Test.php index 52a876dfd..64f5d767c 100644 --- a/tests/Germany/ReformationDay2017Test.php +++ b/tests/Germany/ReformationDay2017Test.php @@ -1,8 +1,11 @@ + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; +use Yasumi\Yasumi; + +class AnniversaryOfIslamicRevolutionTest extends IranBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'anniversaryOfIslamicRevolution'; + + public const ESTABLISHMENT_YEAR = 1979; + + public function testAnniversaryOfIslamicRevolutionBeforeEstablishment(): void + { + $this->assertNotHoliday( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(Yasumi::YEAR_LOWER_BOUND, self::ESTABLISHMENT_YEAR - 1) + ); + } + + /** + * @throws \Exception + */ + public function testAnniversaryOfIslamicRevolutionAfterEstablishment(): void + { + $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-02-11", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(self::ESTABLISHMENT_YEAR), + [ + self::LOCALE => 'انقلاب اسلامی پنجاه و هفت', + 'en' => 'Enqelab e Eslami', + ] + ); + } + + /** + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(self::ESTABLISHMENT_YEAR), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Iran/DeathOfKhomeiniTest.php b/tests/Iran/DeathOfKhomeiniTest.php new file mode 100644 index 000000000..9e5229172 --- /dev/null +++ b/tests/Iran/DeathOfKhomeiniTest.php @@ -0,0 +1,76 @@ + + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; +use Yasumi\Yasumi; + +class DeathOfKhomeiniTest extends IranBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'deathOfKhomeini'; + + public const ESTABLISHMENT_YEAR = 1989; + + public function testDeathOfKhomeiniBeforeEstablishment(): void + { + $this->assertNotHoliday( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(Yasumi::YEAR_LOWER_BOUND, self::ESTABLISHMENT_YEAR - 1) + ); + } + + /** + * @throws \Exception + */ + public function testDeathOfKhomeiniAfterEstablishment(): void + { + $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-06-04", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(self::ESTABLISHMENT_YEAR), + [ + self::LOCALE => 'مرگ خمینی', + 'en' => 'Marg e Khomeini', + ] + ); + } + + /** + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(self::ESTABLISHMENT_YEAR), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Iran/IranBaseTestCase.php b/tests/Iran/IranBaseTestCase.php new file mode 100644 index 000000000..b2afb67ba --- /dev/null +++ b/tests/Iran/IranBaseTestCase.php @@ -0,0 +1,32 @@ + + */ + +namespace Yasumi\tests\Iran; + +use PHPUnit\Framework\TestCase; +use Yasumi\tests\YasumiBase; + +class IranBaseTestCase extends TestCase +{ + use YasumiBase; + + public const REGION = 'Iran'; + + public const TIMEZONE = 'Asia/Tehran'; + + public const LOCALE = 'fa'; +} diff --git a/tests/Iran/IranTest.php b/tests/Iran/IranTest.php new file mode 100644 index 000000000..6c6f0b8fe --- /dev/null +++ b/tests/Iran/IranTest.php @@ -0,0 +1,93 @@ + + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\ProviderTestCase; + +class IranTest extends IranBaseTestCase implements ProviderTestCase +{ + /** + * @var int year random year number used for all tests in this Test Case + */ + protected int $year; + + /** + * @throws \Exception + */ + protected function setUp(): void + { + $this->year = $this->generateRandomYear(); + } + + public function testOfficialHolidays(): void + { + $holidays = [ + 'nowruz1', + 'nowruz2', + 'nowruz3', + 'nowruz4', + 'sizdahBedar', + ]; + + if (1979 <= $this->year) { + $holidays[] = 'islamicRepublicDay'; + $holidays[] = 'revoltOfKhordad15'; + $holidays[] = 'anniversaryOfIslamicRevolution'; + } + + if (1989 <= $this->year) { + $holidays[] = 'deathOfKhomeini'; + } + + if (1951 <= $this->year) { + $holidays[] = 'nationalizationOfTheIranianOilIndustry'; + } + + $this->assertDefinedHolidays($holidays, self::REGION, $this->year, Holiday::TYPE_OFFICIAL); + } + + public function testObservedHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OBSERVANCE); + } + + public function testSeasonalHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_SEASON); + } + + public function testBankHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_BANK); + } + + public function testOtherHolidays(): void + { + $this->assertDefinedHolidays([], self::REGION, $this->year, Holiday::TYPE_OTHER); + } + + /** + * @throws \ReflectionException + * @throws \Exception + */ + public function testSources(): void + { + $this->assertSources(self::REGION, 2); + } +} diff --git a/tests/Iran/IslamicRepublicDayTest.php b/tests/Iran/IslamicRepublicDayTest.php new file mode 100644 index 000000000..1aee7ee8b --- /dev/null +++ b/tests/Iran/IslamicRepublicDayTest.php @@ -0,0 +1,109 @@ + + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; +use Yasumi\Yasumi; + +class IslamicRepublicDayTest extends IranBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'islamicRepublicDay'; + + public const ESTABLISHMENT_YEAR = 1979; + + public const EQUINOX_YEAR = 2016; + + /** + * @throws \Exception + */ + public function testIslamicRepublicDayBeforeEstablishment(): void + { + $this->assertNotHoliday( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(Yasumi::YEAR_LOWER_BOUND, self::ESTABLISHMENT_YEAR - 1) + ); + } + + /** + * @throws \Exception + */ + public function testIslamicRepublicDayBeforeEquinoxYear(): void + { + $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::EQUINOX_YEAR - 1); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-04-01", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testIslamicRepublicDayOnEquinoxYear(): void + { + $year = $this->generateRandomYear(self::EQUINOX_YEAR, self::EQUINOX_YEAR); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-03-31", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testIslamicRepublicDayAfterEquinoxYear(): void + { + $year = $this->generateRandomYear(self::EQUINOX_YEAR + 1); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-04-01", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::EQUINOX_YEAR), + [ + self::LOCALE => 'روز جمهوری اسلامی', + 'en' => 'Ruz e Jomhuri ye Eslami', + ] + ); + } + + /** + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::EQUINOX_YEAR), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Iran/NationalizationOfTheIranianOilIndustryTest.php b/tests/Iran/NationalizationOfTheIranianOilIndustryTest.php new file mode 100644 index 000000000..94f34bb07 --- /dev/null +++ b/tests/Iran/NationalizationOfTheIranianOilIndustryTest.php @@ -0,0 +1,76 @@ + + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; +use Yasumi\Yasumi; + +class NationalizationOfTheIranianOilIndustryTest extends IranBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'nationalizationOfTheIranianOilIndustry'; + + public const ESTABLISHMENT_YEAR = 1951; + + public function testNationalizationOfTheIranianOilIndustryBeforeEstablishment(): void + { + $this->assertNotHoliday( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(Yasumi::YEAR_LOWER_BOUND, self::ESTABLISHMENT_YEAR - 1) + ); + } + + /** + * @throws \Exception + */ + public function testNationalizationOfTheIranianOilIndustryAfterEstablishment(): void + { + $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-03-20", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(self::ESTABLISHMENT_YEAR), + [ + self::LOCALE => 'ملی شدن صنعت نفت', + 'en' => 'Melli Shodan e Saneat e Naft', + ] + ); + } + + /** + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(self::ESTABLISHMENT_YEAR), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Iran/Nowruz1Test.php b/tests/Iran/Nowruz1Test.php new file mode 100644 index 000000000..31926b82e --- /dev/null +++ b/tests/Iran/Nowruz1Test.php @@ -0,0 +1,64 @@ + + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; + +class Nowruz1Test extends IranBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'nowruz1'; + + /** + * @throws \Exception + */ + public function testNowruz1(): void + { + $year = $this->generateRandomYear(); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-03-21", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [ + self::LOCALE => 'نوروز', + 'en' => 'Nowruz', + ] + ); + } + + /** + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Iran/Nowruz2Test.php b/tests/Iran/Nowruz2Test.php new file mode 100644 index 000000000..e1487c75f --- /dev/null +++ b/tests/Iran/Nowruz2Test.php @@ -0,0 +1,64 @@ + + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; + +class Nowruz2Test extends IranBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'nowruz2'; + + /** + * @throws \Exception + */ + public function testNowruz2(): void + { + $year = $this->generateRandomYear(); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-03-22", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [ + self::LOCALE => 'نوروز', + 'en' => 'Nowruz', + ] + ); + } + + /** + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Iran/Nowruz3Test.php b/tests/Iran/Nowruz3Test.php new file mode 100644 index 000000000..51df83842 --- /dev/null +++ b/tests/Iran/Nowruz3Test.php @@ -0,0 +1,64 @@ + + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; + +class Nowruz3Test extends IranBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'nowruz3'; + + /** + * @throws \Exception + */ + public function testNowruz3(): void + { + $year = $this->generateRandomYear(); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-03-23", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [ + self::LOCALE => 'نوروز', + 'en' => 'Nowruz', + ] + ); + } + + /** + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Iran/Nowruz4Test.php b/tests/Iran/Nowruz4Test.php new file mode 100644 index 000000000..9b27e6741 --- /dev/null +++ b/tests/Iran/Nowruz4Test.php @@ -0,0 +1,64 @@ + + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; + +class Nowruz4Test extends IranBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'nowruz4'; + + /** + * @throws \Exception + */ + public function testNowruz4(): void + { + $year = $this->generateRandomYear(); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-03-24", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [ + self::LOCALE => 'نوروز', + 'en' => 'Nowruz', + ] + ); + } + + /** + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Iran/RevoltOfKhordad15Test.php b/tests/Iran/RevoltOfKhordad15Test.php new file mode 100644 index 000000000..7d3b7b07f --- /dev/null +++ b/tests/Iran/RevoltOfKhordad15Test.php @@ -0,0 +1,76 @@ + + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; +use Yasumi\Yasumi; + +class RevoltOfKhordad15Test extends IranBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'revoltOfKhordad15'; + + public const ESTABLISHMENT_YEAR = 1979; + + public function testRevoltOfKhordad15BeforeEstablishment(): void + { + $this->assertNotHoliday( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(Yasumi::YEAR_LOWER_BOUND, self::ESTABLISHMENT_YEAR - 1) + ); + } + + /** + * @throws \Exception + */ + public function testRevoltOfKhordad15AfterEstablishment(): void + { + $year = $this->generateRandomYear(self::ESTABLISHMENT_YEAR); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-06-05", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(self::ESTABLISHMENT_YEAR), + [ + self::LOCALE => 'قیام ۱۵ خرداد', + 'en' => 'Qiam e Panzdah e Khordad', + ] + ); + } + + /** + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(self::ESTABLISHMENT_YEAR), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Iran/SizdahBedarTest.php b/tests/Iran/SizdahBedarTest.php new file mode 100644 index 000000000..84209f767 --- /dev/null +++ b/tests/Iran/SizdahBedarTest.php @@ -0,0 +1,64 @@ + + */ + +namespace Yasumi\tests\Iran; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; + +class SizdahBedarTest extends IranBaseTestCase implements HolidayTestCase +{ + public const HOLIDAY = 'sizdahBedar'; + + /** + * @throws \Exception + */ + public function testSizdahBedar(): void + { + $year = $this->generateRandomYear(); + $this->assertHoliday( + self::REGION, + self::HOLIDAY, + $year, + new \DateTime("{$year}-04-02", new \DateTimeZone(self::TIMEZONE)) + ); + } + + /** + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + $this->generateRandomYear(), + [ + self::LOCALE => 'سیزده بدر', + 'en' => 'Sizdah be dar', + ] + ); + } + + /** + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Ireland/AugustHolidayTest.php b/tests/Ireland/AugustHolidayTest.php index 9dd78782a..d5435af2a 100644 --- a/tests/Ireland/AugustHolidayTest.php +++ b/tests/Ireland/AugustHolidayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->modify('next tuesday'); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/Ireland/EasterMondayTest.php b/tests/Ireland/EasterMondayTest.php index a5865fdd2..f035aeebb 100644 --- a/tests/Ireland/EasterMondayTest.php +++ b/tests/Ireland/EasterMondayTest.php @@ -1,8 +1,11 @@ format('w')) { $date->modify('next monday'); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/Ireland/OctoberHolidayTest.php b/tests/Ireland/OctoberHolidayTest.php index f1bb56ad7..1921bea4e 100644 --- a/tests/Ireland/OctoberHolidayTest.php +++ b/tests/Ireland/OctoberHolidayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->modify('next monday'); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/Ireland/StStephensDayTest.php b/tests/Ireland/StStephensDayTest.php index d3598fe28..7bacde176 100644 --- a/tests/Ireland/StStephensDayTest.php +++ b/tests/Ireland/StStephensDayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->modify('next monday'); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/Ireland/pentecostMondayTest.php b/tests/Ireland/pentecostMondayTest.php index ab6356079..49ccfaaef 100644 --- a/tests/Ireland/pentecostMondayTest.php +++ b/tests/Ireland/pentecostMondayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-5-6", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/ComingOfAgeDayTest.php b/tests/Japan/ComingOfAgeDayTest.php index b41d4864c..86a017c5a 100644 --- a/tests/Japan/ComingOfAgeDayTest.php +++ b/tests/Japan/ComingOfAgeDayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-5-6", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/CoronationDayTest.php b/tests/Japan/CoronationDayTest.php index 46891f10d..da3d5fb82 100644 --- a/tests/Japan/CoronationDayTest.php +++ b/tests/Japan/CoronationDayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-11-4", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/EmperorsBirthdayTest.php b/tests/Japan/EmperorsBirthdayTest.php index ccd57d219..068e8dab1 100644 --- a/tests/Japan/EmperorsBirthdayTest.php +++ b/tests/Japan/EmperorsBirthdayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-12-24", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/EnthronementProclamationCeremonyTest.php b/tests/Japan/EnthronementProclamationCeremonyTest.php index b7d9cafce..8a3c7b79b 100644 --- a/tests/Japan/EnthronementProclamationCeremonyTest.php +++ b/tests/Japan/EnthronementProclamationCeremonyTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-5-6", new \DateTimeZone(self::TIMEZONE)) ); @@ -92,7 +95,7 @@ public function testHolidayBetween1989And2007SubstitutedNextWorkingDay(): void $year = 2001; $this->assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-4-30", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/JapanBaseTestCase.php b/tests/Japan/JapanBaseTestCase.php index 4e1de357c..2f3632964 100644 --- a/tests/Japan/JapanBaseTestCase.php +++ b/tests/Japan/JapanBaseTestCase.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-11-24", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/MarineDayTest.php b/tests/Japan/MarineDayTest.php index 7cecbe5a5..ff800ba81 100644 --- a/tests/Japan/MarineDayTest.php +++ b/tests/Japan/MarineDayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-7-21", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/MountainDayTest.php b/tests/Japan/MountainDayTest.php index 82dff86e3..3e78396c1 100644 --- a/tests/Japan/MountainDayTest.php +++ b/tests/Japan/MountainDayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-8-12", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/NationalFoundationDayTest.php b/tests/Japan/NationalFoundationDayTest.php index 9b44ebac1..f2c44dd7e 100644 --- a/tests/Japan/NationalFoundationDayTest.php +++ b/tests/Japan/NationalFoundationDayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-2-12", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/NewYearsDayTest.php b/tests/Japan/NewYearsDayTest.php index 20ee8384d..de73f3880 100644 --- a/tests/Japan/NewYearsDayTest.php +++ b/tests/Japan/NewYearsDayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-1-2", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/PublicBridgeDayTest.php b/tests/Japan/PublicBridgeDayTest.php index 57888876a..ee83c4bd9 100644 --- a/tests/Japan/PublicBridgeDayTest.php +++ b/tests/Japan/PublicBridgeDayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::HOLIDAY.'1', + self::HOLIDAY . '1', $this->year, new \DateTime("{$this->year}-4-30", new \DateTimeZone(self::TIMEZONE)) ); $this->assertHoliday( self::REGION, - self::HOLIDAY.'2', + self::HOLIDAY . '2', $this->year, new \DateTime("{$this->year}-5-2", new \DateTimeZone(self::TIMEZONE)) ); @@ -66,7 +69,7 @@ public function testPublicBridgeDay(): void */ public function testTranslation(): void { - $this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY.'1', $this->year, [self::LOCALE => '国民の休日']); + $this->assertTranslatedHolidayName(self::REGION, self::HOLIDAY . '1', $this->year, [self::LOCALE => '国民の休日']); } /** @@ -74,6 +77,6 @@ public function testTranslation(): void */ public function testHolidayType(): void { - $this->assertHolidayType(self::REGION, self::HOLIDAY.'1', $this->year, Holiday::TYPE_OFFICIAL); + $this->assertHolidayType(self::REGION, self::HOLIDAY . '1', $this->year, Holiday::TYPE_OFFICIAL); } } diff --git a/tests/Japan/RespectForTheAgedDayTest.php b/tests/Japan/RespectForTheAgedDayTest.php index 3e22e866a..6049e054b 100644 --- a/tests/Japan/RespectForTheAgedDayTest.php +++ b/tests/Japan/RespectForTheAgedDayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-9-16", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/ShowaDayTest.php b/tests/Japan/ShowaDayTest.php index eab7e362f..0c81b4d1c 100644 --- a/tests/Japan/ShowaDayTest.php +++ b/tests/Japan/ShowaDayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-4-30", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/SportsDayTest.php b/tests/Japan/SportsDayTest.php index 5fc299a8b..a0310a248 100644 --- a/tests/Japan/SportsDayTest.php +++ b/tests/Japan/SportsDayTest.php @@ -1,8 +1,11 @@ assertHoliday( self::REGION, - self::SUBSTITUTE_PREFIX.self::HOLIDAY, + self::SUBSTITUTE_PREFIX . self::HOLIDAY, $year, new \DateTime("{$year}-10-11", new \DateTimeZone(self::TIMEZONE)) ); diff --git a/tests/Japan/VernalEquinoxDayTest.php b/tests/Japan/VernalEquinoxDayTest.php index 9eb842e8e..afb09dade 100644 --- a/tests/Japan/VernalEquinoxDayTest.php +++ b/tests/Japan/VernalEquinoxDayTest.php @@ -1,8 +1,11 @@ + */ namespace Yasumi\tests\Mexico; diff --git a/tests/Mexico/ChristmasTest.php b/tests/Mexico/ChristmasTest.php index 50d1f97de..2805ea2b9 100644 --- a/tests/Mexico/ChristmasTest.php +++ b/tests/Mexico/ChristmasTest.php @@ -1,8 +1,11 @@ + */ namespace Yasumi\tests\Mexico; diff --git a/tests/Mexico/VirginOfGuadalupeTest.php b/tests/Mexico/VirginOfGuadalupeTest.php index c8aa40089..f3ef2408e 100644 --- a/tests/Mexico/VirginOfGuadalupeTest.php +++ b/tests/Mexico/VirginOfGuadalupeTest.php @@ -1,6 +1,19 @@ + */ namespace Yasumi\tests\Mexico; diff --git a/tests/Netherlands/AscensionDayTest.php b/tests/Netherlands/AscensionDayTest.php index 7cd8a3195..fbd50b71f 100644 --- a/tests/Netherlands/AscensionDayTest.php +++ b/tests/Netherlands/AscensionDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(self::ESTABLISHMENT_YEAR); $expected = new \DateTime( - (($year < 1910) ? 'second wednesday of october' : 'fourth monday of october')." {$year}", + (($year < 1910) ? 'second wednesday of october' : 'fourth monday of october') . " {$year}", new \DateTimeZone(self::TIMEZONE) ); diff --git a/tests/NewZealand/NewYearsDayTest.php b/tests/NewZealand/NewYearsDayTest.php index 0235227af..fcfd109f8 100644 --- a/tests/NewZealand/NewYearsDayTest.php +++ b/tests/NewZealand/NewYearsDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(self::ESTABLISHMENT_YEAR); + yield $this->generateRandomYear(self::ESTABLISHMENT_YEAR, self::HOLIDAY_YEAR_SUSPENDED - 1); yield self::ESTABLISHMENT_YEAR; } diff --git a/tests/Portugal/RestorationOfIndependenceTest.php b/tests/Portugal/RestorationOfIndependenceTest.php index ca42f26d6..83d975849 100644 --- a/tests/Portugal/RestorationOfIndependenceTest.php +++ b/tests/Portugal/RestorationOfIndependenceTest.php @@ -1,8 +1,11 @@ add(new \DateInterval('P'.$easter_days.'D')); + $easter->add(new \DateInterval('P' . $easter_days . 'D')); return $easter; } diff --git a/tests/Romania/AssumptionOfMaryTest.php b/tests/Romania/AssumptionOfMaryTest.php index 62b6e71a7..8ec922302 100644 --- a/tests/Romania/AssumptionOfMaryTest.php +++ b/tests/Romania/AssumptionOfMaryTest.php @@ -1,8 +1,11 @@ + */ + +namespace Yasumi\tests\Slovakia; + +use Yasumi\Holiday; +use Yasumi\tests\HolidayTestCase; + +/** + * Class for testing an official holiday in Slovakia. + * + * @author Jan Hamrak + */ +class DeclarationOfTheSlovakNationTest extends SlovakiaBaseTestCase implements HolidayTestCase +{ + /** + * The name of the holiday to be tested. + */ + public const HOLIDAY = 'declarationOfTheSlovakNation'; + + /** + * Tests the holiday defined in this test. + * + * @dataProvider HolidayDataProvider + * + * @param int $year the year for which the holiday defined in this test needs to be tested + * @param \DateTime $expected the expected date + */ + public function testHoliday(int $year, \DateTimeInterface $expected): void + { + if (2018 === $year) { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } else { + $this->assertNotHoliday(self::REGION, self::HOLIDAY, $year); + } + } + + /** + * Returns a list of random test dates used for assertion of the holiday defined in this test. + * + * @return array list of test dates for the holiday defined in this test + * + * @throws \Exception + */ + public function HolidayDataProvider(): array + { + return $this->generateRandomDates(10, 30, self::TIMEZONE); + } + + /** + * Tests the translated name of the holiday defined in this test. + * + * @throws \Exception + */ + public function testTranslation(): void + { + $this->assertTranslatedHolidayName( + self::REGION, + self::HOLIDAY, + 2018, + [self::LOCALE => 'Výročie Deklarácie slovenského národa'] + ); + } + + /** + * Tests type of the holiday defined in this test. + * + * @throws \Exception + */ + public function testHolidayType(): void + { + $this->assertHolidayType(self::REGION, self::HOLIDAY, 2018, Holiday::TYPE_OFFICIAL); + } +} diff --git a/tests/Slovakia/EasterMondayTest.php b/tests/Slovakia/EasterMondayTest.php index a02cd8879..66816e2ac 100644 --- a/tests/Slovakia/EasterMondayTest.php +++ b/tests/Slovakia/EasterMondayTest.php @@ -1,9 +1,11 @@ assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + if ($year < 2024) { + $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $expected); + } else { + $this->assertNotHoliday(self::REGION, self::HOLIDAY, $year); + } } /** @@ -65,7 +71,7 @@ public function testTranslation(): void $this->assertTranslatedHolidayName( self::REGION, self::HOLIDAY, - $this->generateRandomYear(), + $this->generateRandomYear(null, 2013), [self::LOCALE => 'Deň Ústavy Slovenskej republiky'] ); } @@ -77,6 +83,6 @@ public function testTranslation(): void */ public function testHolidayType(): void { - $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(), Holiday::TYPE_OFFICIAL); + $this->assertHolidayType(self::REGION, self::HOLIDAY, $this->generateRandomYear(null, 2013), Holiday::TYPE_OFFICIAL); } } diff --git a/tests/Slovakia/SlovakIndependenceDayTest.php b/tests/Slovakia/SlovakIndependenceDayTest.php index 26447fdaf..9b84dbb25 100644 --- a/tests/Slovakia/SlovakIndependenceDayTest.php +++ b/tests/Slovakia/SlovakIndependenceDayTest.php @@ -1,9 +1,11 @@ assertDefinedHolidays([ 'slovakIndependenceDay', - 'slovakConstitutionDay', 'slovakNationalUprisingDay', 'saintsCyrilAndMethodiusDay', 'struggleForFreedomAndDemocracyDay', ], self::REGION, $this->year, Holiday::TYPE_OFFICIAL); + + $this->assertDefinedHolidays([ + 'slovakConstitutionDay', + ], self::REGION, 2013, Holiday::TYPE_OFFICIAL); + + $this->assertDefinedHolidays([ + 'declarationOfTheSlovakNation', + ], self::REGION, 2018, Holiday::TYPE_OFFICIAL); } /** diff --git a/tests/Slovakia/StruggleForFreedomAndDemocracyDayTest.php b/tests/Slovakia/StruggleForFreedomAndDemocracyDayTest.php index 38b58fbf1..6f0c041ed 100644 --- a/tests/Slovakia/StruggleForFreedomAndDemocracyDayTest.php +++ b/tests/Slovakia/StruggleForFreedomAndDemocracyDayTest.php @@ -1,9 +1,11 @@ format('w')) { $date->add(new \DateInterval('P1D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/SouthAfrica/FamilyDayTest.php b/tests/SouthAfrica/FamilyDayTest.php index 3ba096b5a..909f05e58 100644 --- a/tests/SouthAfrica/FamilyDayTest.php +++ b/tests/SouthAfrica/FamilyDayTest.php @@ -1,8 +1,11 @@ format('w')) { $date->add(new \DateInterval('P1D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/SouthAfrica/GoodFridayTest.php b/tests/SouthAfrica/GoodFridayTest.php index 60148fabe..9b35b3aaf 100644 --- a/tests/SouthAfrica/GoodFridayTest.php +++ b/tests/SouthAfrica/GoodFridayTest.php @@ -1,8 +1,11 @@ format('w')) { $date->add(new \DateInterval('P1D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/SouthAfrica/HumanRightsDayTest.php b/tests/SouthAfrica/HumanRightsDayTest.php index 140196022..05bd17211 100644 --- a/tests/SouthAfrica/HumanRightsDayTest.php +++ b/tests/SouthAfrica/HumanRightsDayTest.php @@ -1,8 +1,11 @@ format('w')) { $date->add(new \DateInterval('P1D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/SouthAfrica/MunicipalElections2016DayTest.php b/tests/SouthAfrica/MunicipalElections2016DayTest.php index 45ba0b67a..84513dfe5 100644 --- a/tests/SouthAfrica/MunicipalElections2016DayTest.php +++ b/tests/SouthAfrica/MunicipalElections2016DayTest.php @@ -1,8 +1,11 @@ format('w')) { $date->add(new \DateInterval('P1D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/SouthAfrica/NewYearsDayTest.php b/tests/SouthAfrica/NewYearsDayTest.php index f37033346..20f989c6c 100644 --- a/tests/SouthAfrica/NewYearsDayTest.php +++ b/tests/SouthAfrica/NewYearsDayTest.php @@ -1,8 +1,11 @@ format('w')) { $date->add(new \DateInterval('P1D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/SouthAfrica/ReconciliationDayTest.php b/tests/SouthAfrica/ReconciliationDayTest.php index 47199f0a9..9e9f1561c 100644 --- a/tests/SouthAfrica/ReconciliationDayTest.php +++ b/tests/SouthAfrica/ReconciliationDayTest.php @@ -1,8 +1,11 @@ format('w')) { $date->add(new \DateInterval('P1D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/SouthAfrica/SecondChristmasDayTest.php b/tests/SouthAfrica/SecondChristmasDayTest.php index 44f9f09a0..ba97fa6b1 100644 --- a/tests/SouthAfrica/SecondChristmasDayTest.php +++ b/tests/SouthAfrica/SecondChristmasDayTest.php @@ -1,8 +1,11 @@ format('w')) { $date->add(new \DateInterval('P1D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/SouthAfrica/SouthAfricaBaseTestCase.php b/tests/SouthAfrica/SouthAfricaBaseTestCase.php index eee3b1b57..e98efa0d5 100644 --- a/tests/SouthAfrica/SouthAfricaBaseTestCase.php +++ b/tests/SouthAfrica/SouthAfricaBaseTestCase.php @@ -1,9 +1,11 @@ format('w')) { $date->add(new \DateInterval('P1D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/SouthAfrica/YouthDayTest.php b/tests/SouthAfrica/YouthDayTest.php index a38271a88..1e8dd5e9a 100644 --- a/tests/SouthAfrica/YouthDayTest.php +++ b/tests/SouthAfrica/YouthDayTest.php @@ -1,8 +1,11 @@ format('w')) { $date->add(new \DateInterval('P1D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/SouthKorea/ArborDayTest.php b/tests/SouthKorea/ArborDayTest.php index c93ff92a4..9cdf7f4dc 100644 --- a/tests/SouthKorea/ArborDayTest.php +++ b/tests/SouthKorea/ArborDayTest.php @@ -1,9 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Bern/BernBaseTestCase.php b/tests/Switzerland/Bern/BernBaseTestCase.php index 16b755b95..526a7c5b9 100644 --- a/tests/Switzerland/Bern/BernBaseTestCase.php +++ b/tests/Switzerland/Bern/BernBaseTestCase.php @@ -1,8 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Fribourg/ChristmasDayTest.php b/tests/Switzerland/Fribourg/ChristmasDayTest.php index b403b28c2..189ecd63e 100644 --- a/tests/Switzerland/Fribourg/ChristmasDayTest.php +++ b/tests/Switzerland/Fribourg/ChristmasDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(1870, 1965); // Find first Sunday of September - $date = new \DateTime('First Sunday of '.$year.'-09', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime('First Sunday of ' . $year . '-09', new \DateTimeZone(self::TIMEZONE)); // Go to next Thursday $date->add(new \DateInterval('P4D')); @@ -54,7 +57,7 @@ public function testJeuneGenevoisBetween1840And1869(): void { $year = $this->generateRandomYear(Geneva::JEUNE_GENEVOIS_ESTABLISHMENT_YEAR, 1869); // Find first Sunday of September - $date = new \DateTime('First Sunday of '.$year.'-09', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime('First Sunday of ' . $year . '-09', new \DateTimeZone(self::TIMEZONE)); // Go to next Thursday $date->add(new \DateInterval('P4D')); diff --git a/tests/Switzerland/Geneva/NewYearsDayTest.php b/tests/Switzerland/Geneva/NewYearsDayTest.php index 7c02946a7..e17861f8b 100644 --- a/tests/Switzerland/Geneva/NewYearsDayTest.php +++ b/tests/Switzerland/Geneva/NewYearsDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Glarus/ChristmasDayTest.php b/tests/Switzerland/Glarus/ChristmasDayTest.php index f492a03b9..9a99a5b39 100644 --- a/tests/Switzerland/Glarus/ChristmasDayTest.php +++ b/tests/Switzerland/Glarus/ChristmasDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(self::ESTABLISHMENT_YEAR); - $date = new \DateTime('First Thursday of '.$year.'-04', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime('First Thursday of ' . $year . '-04', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); } diff --git a/tests/Switzerland/Glarus/NewYearsDayTest.php b/tests/Switzerland/Glarus/NewYearsDayTest.php index 590e512c3..eef7dc1c9 100644 --- a/tests/Switzerland/Glarus/NewYearsDayTest.php +++ b/tests/Switzerland/Glarus/NewYearsDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Jura/BettagsMontagTest.php b/tests/Switzerland/Jura/BettagsMontagTest.php index 3064c4486..101d0c521 100644 --- a/tests/Switzerland/Jura/BettagsMontagTest.php +++ b/tests/Switzerland/Jura/BettagsMontagTest.php @@ -1,8 +1,11 @@ generateRandomYear(1832); // Find third Sunday of September - $date = new \DateTime('Third Sunday of '.$year.'-09', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime('Third Sunday of ' . $year . '-09', new \DateTimeZone(self::TIMEZONE)); // Go to next Thursday $date->add(new \DateInterval('P1D')); diff --git a/tests/Switzerland/Jura/ChristmasDayTest.php b/tests/Switzerland/Jura/ChristmasDayTest.php index 12b6cbc4b..497d27546 100644 --- a/tests/Switzerland/Jura/ChristmasDayTest.php +++ b/tests/Switzerland/Jura/ChristmasDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Lucerne/ChristmasDayTest.php b/tests/Switzerland/Lucerne/ChristmasDayTest.php index 286c4de51..902103361 100644 --- a/tests/Switzerland/Lucerne/ChristmasDayTest.php +++ b/tests/Switzerland/Lucerne/ChristmasDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(1832); // Find third Sunday of September - $date = new \DateTime('Third Sunday of '.$year.'-09', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime('Third Sunday of ' . $year . '-09', new \DateTimeZone(self::TIMEZONE)); // Go to next Thursday $date->add(new \DateInterval('P1D')); diff --git a/tests/Switzerland/Neuchatel/ChristmasDayTest.php b/tests/Switzerland/Neuchatel/ChristmasDayTest.php index 55702460a..7a67c3d84 100644 --- a/tests/Switzerland/Neuchatel/ChristmasDayTest.php +++ b/tests/Switzerland/Neuchatel/ChristmasDayTest.php @@ -1,8 +1,11 @@ assertNotHoliday( self::REGION, diff --git a/tests/Switzerland/Neuchatel/EasterMondayTest.php b/tests/Switzerland/Neuchatel/EasterMondayTest.php index 5c7b1eeb6..b866834be 100644 --- a/tests/Switzerland/Neuchatel/EasterMondayTest.php +++ b/tests/Switzerland/Neuchatel/EasterMondayTest.php @@ -1,8 +1,11 @@ assertNotHoliday( self::REGION, diff --git a/tests/Switzerland/Neuchatel/NeuchatelBaseTestCase.php b/tests/Switzerland/Neuchatel/NeuchatelBaseTestCase.php index f801e056c..85406b8d5 100644 --- a/tests/Switzerland/Neuchatel/NeuchatelBaseTestCase.php +++ b/tests/Switzerland/Neuchatel/NeuchatelBaseTestCase.php @@ -1,8 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Obwalden/BruderKlausenFestTest.php b/tests/Switzerland/Obwalden/BruderKlausenFestTest.php index a7b8811cf..d3d5befea 100644 --- a/tests/Switzerland/Obwalden/BruderKlausenFestTest.php +++ b/tests/Switzerland/Obwalden/BruderKlausenFestTest.php @@ -1,8 +1,11 @@ generateRandomYear(1947); - $date = new \DateTime($year.'-09-25', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-09-25', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); @@ -49,7 +52,7 @@ public function testBruderKlausenFestOnAfter1947(): void public function testBruderKlausenFestBetween1649And1946(): void { $year = $this->generateRandomYear(1649, 1946); - $date = new \DateTime($year.'-09-21', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-09-21', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Obwalden/ChristmasDayTest.php b/tests/Switzerland/Obwalden/ChristmasDayTest.php index 7467fec14..224330c64 100644 --- a/tests/Switzerland/Obwalden/ChristmasDayTest.php +++ b/tests/Switzerland/Obwalden/ChristmasDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Schaffhausen/ChristmasDayTest.php b/tests/Switzerland/Schaffhausen/ChristmasDayTest.php index 9d4edda92..a44947a49 100644 --- a/tests/Switzerland/Schaffhausen/ChristmasDayTest.php +++ b/tests/Switzerland/Schaffhausen/ChristmasDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Solothurn/ChristmasDayTest.php b/tests/Switzerland/Solothurn/ChristmasDayTest.php index 599f801c3..dd0d43ed4 100644 --- a/tests/Switzerland/Solothurn/ChristmasDayTest.php +++ b/tests/Switzerland/Solothurn/ChristmasDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Thurgau/ChristmasDayTest.php b/tests/Switzerland/Thurgau/ChristmasDayTest.php index 908fb1e04..3c5c99fc9 100644 --- a/tests/Switzerland/Thurgau/ChristmasDayTest.php +++ b/tests/Switzerland/Thurgau/ChristmasDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Vaud/BettagsMontagTest.php b/tests/Switzerland/Vaud/BettagsMontagTest.php index 8b0e91909..368a363e3 100644 --- a/tests/Switzerland/Vaud/BettagsMontagTest.php +++ b/tests/Switzerland/Vaud/BettagsMontagTest.php @@ -1,8 +1,11 @@ generateRandomYear(1832); // Find third Sunday of September - $date = new \DateTime('Third Sunday of '.$year.'-09', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime('Third Sunday of ' . $year . '-09', new \DateTimeZone(self::TIMEZONE)); // Go to next Thursday $date->add(new \DateInterval('P1D')); diff --git a/tests/Switzerland/Vaud/ChristmasDayTest.php b/tests/Switzerland/Vaud/ChristmasDayTest.php index 9301bd460..8a3637139 100644 --- a/tests/Switzerland/Vaud/ChristmasDayTest.php +++ b/tests/Switzerland/Vaud/ChristmasDayTest.php @@ -1,8 +1,11 @@ generateRandomYear(); - $date = new \DateTime($year.'-01-02', new \DateTimeZone(self::TIMEZONE)); + $date = new \DateTime($year . '-01-02', new \DateTimeZone(self::TIMEZONE)); $this->assertHoliday(self::REGION, self::HOLIDAY, $year, $date); $this->assertHolidayType(self::REGION, self::HOLIDAY, $year, Holiday::TYPE_OTHER); diff --git a/tests/Switzerland/Zug/ChristmasDayTest.php b/tests/Switzerland/Zug/ChristmasDayTest.php index 0c4be41fe..8efb9e1b2 100644 --- a/tests/Switzerland/Zug/ChristmasDayTest.php +++ b/tests/Switzerland/Zug/ChristmasDayTest.php @@ -1,8 +1,11 @@ isHoliday($holidayOfficial)); self::assertEquals(Holiday::TYPE_OFFICIAL, $holidayOfficial->getType()); - $holidaySubstitution = $holidays->getHoliday('substituteHoliday:'.$holidayOfficial->getKey()); + $holidaySubstitution = $holidays->getHoliday('substituteHoliday:' . $holidayOfficial->getKey()); if (! $expectedSubstitution instanceof \DateTimeInterface) { // without substitution diff --git a/tests/Ukraine/UkraineBaseTestCase.php b/tests/Ukraine/UkraineBaseTestCase.php index b9ad9b170..8dbd4567d 100644 --- a/tests/Ukraine/UkraineBaseTestCase.php +++ b/tests/Ukraine/UkraineBaseTestCase.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); - $this->assertHolidayType(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, Holiday::TYPE_BANK); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); + $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK); } } diff --git a/tests/UnitedKingdom/ChristmasDayTest.php b/tests/UnitedKingdom/ChristmasDayTest.php index d28c1e02f..93827c0ae 100644 --- a/tests/UnitedKingdom/ChristmasDayTest.php +++ b/tests/UnitedKingdom/ChristmasDayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); - $this->assertHolidayType(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, Holiday::TYPE_BANK); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); + $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK); } } diff --git a/tests/UnitedKingdom/EasterMondayTest.php b/tests/UnitedKingdom/EasterMondayTest.php index c8e6f51a2..309d2082f 100644 --- a/tests/UnitedKingdom/EasterMondayTest.php +++ b/tests/UnitedKingdom/EasterMondayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); - $this->assertHolidayType(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, Holiday::TYPE_BANK); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); + $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK); } } diff --git a/tests/UnitedKingdom/England/ChristmasDayTest.php b/tests/UnitedKingdom/England/ChristmasDayTest.php index ccb38f337..3cd366bca 100644 --- a/tests/UnitedKingdom/England/ChristmasDayTest.php +++ b/tests/UnitedKingdom/England/ChristmasDayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); - $this->assertHolidayType(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, Holiday::TYPE_BANK); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); + $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK); } } diff --git a/tests/UnitedKingdom/England/EasterMondayTest.php b/tests/UnitedKingdom/England/EasterMondayTest.php index 9f71c5ea2..53ddde421 100644 --- a/tests/UnitedKingdom/England/EasterMondayTest.php +++ b/tests/UnitedKingdom/England/EasterMondayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->modify('next monday'); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/UnitedKingdom/NorthernIreland/BoxingDayTest.php b/tests/UnitedKingdom/NorthernIreland/BoxingDayTest.php index 9af416e6c..6dfeac991 100644 --- a/tests/UnitedKingdom/NorthernIreland/BoxingDayTest.php +++ b/tests/UnitedKingdom/NorthernIreland/BoxingDayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); - $this->assertHolidayType(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, Holiday::TYPE_BANK); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); + $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK); } } diff --git a/tests/UnitedKingdom/NorthernIreland/ChristmasDayTest.php b/tests/UnitedKingdom/NorthernIreland/ChristmasDayTest.php index e8e7fbaf0..e54f944cc 100644 --- a/tests/UnitedKingdom/NorthernIreland/ChristmasDayTest.php +++ b/tests/UnitedKingdom/NorthernIreland/ChristmasDayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); - $this->assertHolidayType(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, Holiday::TYPE_BANK); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); + $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK); } } diff --git a/tests/UnitedKingdom/NorthernIreland/EasterMondayTest.php b/tests/UnitedKingdom/NorthernIreland/EasterMondayTest.php index ab46f8a46..912e35572 100644 --- a/tests/UnitedKingdom/NorthernIreland/EasterMondayTest.php +++ b/tests/UnitedKingdom/NorthernIreland/EasterMondayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->modify('next monday'); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/UnitedKingdom/NorthernIreland/SummerBankHolidayTest.php b/tests/UnitedKingdom/NorthernIreland/SummerBankHolidayTest.php index fe912a8c3..a9198c914 100644 --- a/tests/UnitedKingdom/NorthernIreland/SummerBankHolidayTest.php +++ b/tests/UnitedKingdom/NorthernIreland/SummerBankHolidayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); - $this->assertHolidayType(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, Holiday::TYPE_BANK); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); + $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK); } } diff --git a/tests/UnitedKingdom/Scotland/ChristmasDayTest.php b/tests/UnitedKingdom/Scotland/ChristmasDayTest.php index b089a2ba3..2a12100b7 100644 --- a/tests/UnitedKingdom/Scotland/ChristmasDayTest.php +++ b/tests/UnitedKingdom/Scotland/ChristmasDayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); - $this->assertHolidayType(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, Holiday::TYPE_BANK); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); + $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK); } } diff --git a/tests/UnitedKingdom/Scotland/GoodFridayTest.php b/tests/UnitedKingdom/Scotland/GoodFridayTest.php index caf8d596f..7369c6a8d 100644 --- a/tests/UnitedKingdom/Scotland/GoodFridayTest.php +++ b/tests/UnitedKingdom/Scotland/GoodFridayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/UnitedKingdom/Scotland/ScotlandBaseTestCase.php b/tests/UnitedKingdom/Scotland/ScotlandBaseTestCase.php index b62cb9b0c..c76e60658 100644 --- a/tests/UnitedKingdom/Scotland/ScotlandBaseTestCase.php +++ b/tests/UnitedKingdom/Scotland/ScotlandBaseTestCase.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/UnitedKingdom/Scotland/SpringBankHolidayTest.php b/tests/UnitedKingdom/Scotland/SpringBankHolidayTest.php index 5ea15793a..df7799ba9 100644 --- a/tests/UnitedKingdom/Scotland/SpringBankHolidayTest.php +++ b/tests/UnitedKingdom/Scotland/SpringBankHolidayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->modify('next monday'); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); } } diff --git a/tests/UnitedKingdom/Scotland/SummerBankHolidayTest.php b/tests/UnitedKingdom/Scotland/SummerBankHolidayTest.php index 3d24bb8e2..c7c1c959d 100644 --- a/tests/UnitedKingdom/Scotland/SummerBankHolidayTest.php +++ b/tests/UnitedKingdom/Scotland/SummerBankHolidayTest.php @@ -1,8 +1,11 @@ generateRandomYear(); diff --git a/tests/UnitedKingdom/Wales/BoxingDayTest.php b/tests/UnitedKingdom/Wales/BoxingDayTest.php index 2fd34f441..9f770fcb6 100644 --- a/tests/UnitedKingdom/Wales/BoxingDayTest.php +++ b/tests/UnitedKingdom/Wales/BoxingDayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); - $this->assertHolidayType(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, Holiday::TYPE_BANK); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); + $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK); } } diff --git a/tests/UnitedKingdom/Wales/ChristmasDayTest.php b/tests/UnitedKingdom/Wales/ChristmasDayTest.php index 83ef0087d..1a4114773 100644 --- a/tests/UnitedKingdom/Wales/ChristmasDayTest.php +++ b/tests/UnitedKingdom/Wales/ChristmasDayTest.php @@ -1,8 +1,11 @@ format('w'), [0, 6], true)) { $date->add(new \DateInterval('P2D')); - $this->assertHoliday(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, $date); - $this->assertHolidayType(self::REGION, 'substituteHoliday:'.self::HOLIDAY, $year, Holiday::TYPE_BANK); + $this->assertHoliday(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, $date); + $this->assertHolidayType(self::REGION, 'substituteHoliday:' . self::HOLIDAY, $year, Holiday::TYPE_BANK); } } diff --git a/tests/UnitedKingdom/Wales/EasterMondayTest.php b/tests/UnitedKingdom/Wales/EasterMondayTest.php index 5154f67d5..1c825e6b6 100644 --- a/tests/UnitedKingdom/Wales/EasterMondayTest.php +++ b/tests/UnitedKingdom/Wales/EasterMondayTest.php @@ -1,8 +1,11 @@ getHoliday('substituteHoliday:'.$key); + $holiday = $holidays->getHoliday('substituteHoliday:' . $key); self::assertInstanceOf(SubstituteHoliday::class, $holiday); $this->assertDateTime($expected, $holiday); @@ -152,7 +154,7 @@ public function assertNotSubstituteHoliday( ): void { $this->assertNotHoliday( $provider, - 'substituteHoliday:'.$key, + 'substituteHoliday:' . $key, $year ); }