-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from umulmrum/feature/estonia
Add holidays for Estonia
- Loading branch information
Showing
9 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the umulmrum/holiday package. | ||
* | ||
* (c) Stefan Kruppa | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Umulmrum\Holiday\Provider\Estonia; | ||
|
||
use Umulmrum\Holiday\Constant\HolidayName; | ||
use Umulmrum\Holiday\Constant\HolidayType; | ||
use Umulmrum\Holiday\Model\Holiday; | ||
use Umulmrum\Holiday\Model\HolidayList; | ||
use Umulmrum\Holiday\Provider\CommonHolidaysTrait; | ||
use Umulmrum\Holiday\Provider\HolidayProviderInterface; | ||
use Umulmrum\Holiday\Provider\Religion\ChristianHolidaysTrait; | ||
|
||
use function array_filter; | ||
|
||
class Estonia implements HolidayProviderInterface | ||
{ | ||
use ChristianHolidaysTrait; | ||
use CommonHolidaysTrait; | ||
|
||
public function calculateHolidaysForYear(int $year): HolidayList | ||
{ | ||
return new HolidayList(array_filter([ | ||
$this->getNewYear($year, HolidayType::DAY_OFF), | ||
$this->getIndependenceDay($year, HolidayType::DAY_OFF), | ||
$this->getGoodFriday($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF | HolidayType::PARTIAL_ONLY), | ||
$this->getEasterSunday($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF), | ||
$this->getSpringDay($year, HolidayType::DAY_OFF), | ||
$this->getWhitSunday($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF), | ||
$this->getVictoryDay($year, HolidayType::DAY_OFF), | ||
$this->getMidsummersDay($year, HolidayType::DAY_OFF), | ||
$this->getIndependenceRestorationDay($year, HolidayType::DAY_OFF), | ||
$this->getChristmasEve($year, HolidayType::DAY_OFF | HolidayType::PARTIAL_ONLY), | ||
$this->getChristmasDay($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF), | ||
$this->getSecondChristmasDay($year, HolidayType::OFFICIAL | HolidayType::DAY_OFF), | ||
])); | ||
} | ||
|
||
protected function getMidsummersDay(int $year, int $additionalType = HolidayType::OTHER): Holiday | ||
{ | ||
return Holiday::create(HolidayName::MIDSUMMERS_DAY, "{$year}-06-24", HolidayType::OFFICIAL | $additionalType); | ||
} | ||
|
||
protected function getIndependenceDay(int $year, int $additionalType = HolidayType::OTHER): Holiday | ||
{ | ||
return Holiday::create(HolidayName::ESTONIA_INDEPENDENCE_DAY, "{$year}-02-24", HolidayType::OFFICIAL | $additionalType); | ||
} | ||
|
||
protected function getSpringDay(int $year, int $additionalType = HolidayType::OTHER): Holiday | ||
{ | ||
return Holiday::create(HolidayName::SPRING_DAY, "{$year}-05-01", HolidayType::OFFICIAL | $additionalType); | ||
} | ||
|
||
protected function getVictoryDay(int $year, int $additionalType = HolidayType::OTHER): ?Holiday | ||
{ | ||
return Holiday::create(HolidayName::ESTONIA_VICTORY_DAY, "{$year}-06-23", HolidayType::OFFICIAL | $additionalType); | ||
} | ||
|
||
protected function getIndependenceRestorationDay(int $year, int $additionalType = HolidayType::OTHER): ?Holiday | ||
{ | ||
return $year >= 1998 | ||
? Holiday::create(HolidayName::INDEPENDENCE_RESTORATION_DAY, "{$year}-08-20", HolidayType::OFFICIAL | $additionalType) | ||
: null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters