Skip to content

Commit

Permalink
Formatting fixes.
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Telgenhof <[email protected]>
  • Loading branch information
stelgenhof committed Jan 22, 2018
1 parent f088c88 commit 36e422e
Show file tree
Hide file tree
Showing 15 changed files with 187 additions and 265 deletions.
49 changes: 22 additions & 27 deletions src/Yasumi/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,11 @@
*/
abstract class AbstractProvider implements ProviderInterface, Countable, IteratorAggregate
{
/**
* @var int the object's current year
*/
protected $year;

/**
* @var string the object's current timezone
*/
protected $timezone;

/**
* @var string the object's current locale
*/
protected $locale;

/**
* Code to identify the Holiday Provider. Typically this is the ISO3166 code corresponding to the respective
* country or sub-region.
*/
const ID = 'US';

/**
* @var array list of the days of the week (the index of the weekdays) that are considered weekend days.
* This list only concerns those countries that deviate from the global common definition,
Expand Down Expand Up @@ -84,7 +68,18 @@ abstract class AbstractProvider implements ProviderInterface, Countable, Iterato
// Friday
'IN' => [0], // India
];

/**
* @var int the object's current year
*/
protected $year;
/**
* @var string the object's current timezone
*/
protected $timezone;
/**
* @var string the object's current locale
*/
protected $locale;
/**
* @var Holiday[] list of dates of the available holidays
*/
Expand Down Expand Up @@ -292,16 +287,6 @@ public function count()
return count(array_unique($list));
}

/**
* Gets all of the holidays defined by this holiday provider (for the given year).
*
* @return Holiday[] list of all holidays defined for the given year
*/
public function getHolidays()
{
return $this->holidays;
}

/**
* Gets all of the holiday names defined by this holiday provider (for the given year).
*
Expand Down Expand Up @@ -382,6 +367,16 @@ public function getHoliday($shortName)
return isset($holidays[$shortName]) ? $holidays[$shortName] : null;
}

/**
* Gets all of the holidays defined by this holiday provider (for the given year).
*
* @return Holiday[] list of all holidays defined for the given year
*/
public function getHolidays()
{
return $this->holidays;
}

/**
* Retrieves the previous date (year) the given holiday took place.
*
Expand Down
24 changes: 6 additions & 18 deletions src/Yasumi/Provider/Estonia.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,10 @@ public function initialize()
private function addIndependenceDay()
{
if ($this->year >= self::DECLARATION_OF_INDEPENDENCE_YEAR) {
$this->addHoliday(new Holiday(
'independenceDay',
[
$this->addHoliday(new Holiday('independenceDay', [
'en_US' => 'Independence Day',
'et_EE' => 'Iseseisvuspäev'
],
new \DateTime("{$this->year}-02-24", new \DateTimeZone($this->timezone))
));
], new \DateTime("{$this->year}-02-24", new \DateTimeZone($this->timezone))));
}
}

Expand All @@ -84,14 +80,10 @@ private function addIndependenceDay()
private function addVictoryDay()
{
if ($this->year >= self::VICTORY_DAY_START_YEAR) {
$this->addHoliday(new Holiday(
'victoryDay',
[
$this->addHoliday(new Holiday('victoryDay', [
'en_US' => 'Victory Day',
'et_EE' => 'Võidupüha'
],
new \DateTime("{$this->year}-06-23", new \DateTimeZone($this->timezone))
));
], new \DateTime("{$this->year}-06-23", new \DateTimeZone($this->timezone))));
}
}

Expand All @@ -101,14 +93,10 @@ private function addVictoryDay()
private function addRestorationOfIndependenceDay()
{
if ($this->year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) {
$this->addHoliday(new Holiday(
'restorationOfIndependenceDay',
[
$this->addHoliday(new Holiday('restorationOfIndependenceDay', [
'en_US' => 'Day of Restoration of Independence',
'et_EE' => 'Tasiseseisvumispäev'
],
new \DateTime("{$this->year}-08-20", new \DateTimeZone($this->timezone))
));
], new \DateTime("{$this->year}-08-20", new \DateTimeZone($this->timezone))));
}
}
}
36 changes: 10 additions & 26 deletions src/Yasumi/Provider/Latvia.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,14 @@ private function addRestorationOfIndependenceDay()
if ($this->year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) {
$date = new \DateTime("{$this->year}-05-04", new \DateTimeZone($this->timezone));

if (!$this->isWorkingDay($date)) {
if (! $this->isWorkingDay($date)) {
$date->modify('next monday');
}

$this->addHoliday(new Holiday(
'restorationOfIndependenceOfLatviaDay',
[
$this->addHoliday(new Holiday('restorationOfIndependenceOfLatviaDay', [
'en_US' => 'Restoration of Independence day',
'lv_LV' => 'Latvijas Republikas Neatkarības atjaunošanas diena'
],
$date
));
], $date));
}
}

Expand All @@ -91,14 +87,10 @@ private function addRestorationOfIndependenceDay()
*/
private function addMidsummerEveDay()
{
$this->addHoliday(new Holiday(
'midsummerEveDay',
[
$this->addHoliday(new Holiday('midsummerEveDay', [
'en_US' => 'Midsummer Eve',
'lv_LV' => 'Līgo Diena'
],
new \DateTime("{$this->year}-06-23", new \DateTimeZone($this->timezone))
));
], new \DateTime("{$this->year}-06-23", new \DateTimeZone($this->timezone))));
}

/**
Expand All @@ -112,18 +104,14 @@ private function addProclamationDay()
if ($this->year >= self::PROCLAMATION_OF_INDEPENDENCE_YEAR) {
$date = new \DateTime("{$this->year}-11-18", new \DateTimeZone($this->timezone));

if (!$this->isWorkingDay($date)) {
if (! $this->isWorkingDay($date)) {
$date->modify('next monday');
}

$this->addHoliday(new Holiday(
'proclamationOfTheRepublicOfLatviaDay',
[
$this->addHoliday(new Holiday('proclamationOfTheRepublicOfLatviaDay', [
'en_US' => 'Proclamation Day of the Republic of Latvia',
'lv_LV' => 'Latvijas Republikas proklamēšanas diena'
],
$date
));
], $date));
}
}

Expand All @@ -132,13 +120,9 @@ private function addProclamationDay()
*/
private function addNewYearsEve()
{
$this->addHoliday(new Holiday(
'newYearsEve',
[
$this->addHoliday(new Holiday('newYearsEve', [
'en_US' => 'New Year\'s Eve',
'lv_LV' => 'Vecgada vakars'
],
new \DateTime("{$this->year}-12-31", new \DateTimeZone($this->timezone))
));
], new \DateTime("{$this->year}-12-31", new \DateTimeZone($this->timezone))));
}
}
25 changes: 6 additions & 19 deletions src/Yasumi/Provider/Lithuania.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,10 @@ public function initialize()
private function addRestorationOfTheStateDay()
{
if ($this->year >= self::RESTORATION_OF_THE_STATE_YEAR) {
$this->addHoliday(new Holiday(
'restorationOfTheStateOfLithuaniaDay',
[
$this->addHoliday(new Holiday('restorationOfTheStateOfLithuaniaDay', [
'en_US' => 'Day of Restoration of the State of Lithuania',
'lt_LT' => 'Lietuvos valstybės atkūrimo diena'
],
new \DateTime("{$this->year}-02-16", new \DateTimeZone($this->timezone))
));
], new \DateTime("{$this->year}-02-16", new \DateTimeZone($this->timezone))));
}
}

Expand All @@ -98,14 +94,10 @@ private function addRestorationOfTheStateDay()
private function addRestorationOfIndependenceDay()
{
if ($this->year >= self::RESTORATION_OF_INDEPENDENCE_YEAR) {
$this->addHoliday(new Holiday(
'restorationOfIndependenceOfLithuaniaDay',
[
$this->addHoliday(new Holiday('restorationOfIndependenceOfLithuaniaDay', [
'en_US' => 'Day of Restoration of Independence of Lithuania',
'lt_LT' => 'Lietuvos nepriklausomybės atkūrimo diena'
],
new \DateTime("{$this->year}-03-11", new \DateTimeZone($this->timezone))
));
], new \DateTime("{$this->year}-03-11", new \DateTimeZone($this->timezone))));
}
}

Expand All @@ -118,15 +110,10 @@ private function addRestorationOfIndependenceDay()
private function addStatehoodDay()
{
if ($this->year >= self::STATEHOOD_YEAR) {
$this->addHoliday(new Holiday(
'statehoodDay',
[
$this->addHoliday(new Holiday('statehoodDay', [
'en_US' => 'Statehood Day (Lithuania)',
'lt_LT' => 'Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) diena'
],
new \DateTime("{$this->year}-07-06", new \DateTimeZone($this->timezone)),
$this->locale
));
], new \DateTime("{$this->year}-07-06", new \DateTimeZone($this->timezone)), $this->locale));
}
}
}
12 changes: 6 additions & 6 deletions src/Yasumi/Provider/Romania.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ public function calculateConstantinBrancusiDay()
$this->addHoliday(new Holiday(
'constantinBrancusiDay',
[
'en_US' => 'Constantin Brâncuși day',
'ro_RO' => 'Ziua Constantin Brâncuși'
],
'en_US' => 'Constantin Brâncuși day',
'ro_RO' => 'Ziua Constantin Brâncuși'
],
new DateTime("$this->year-02-19", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_OBSERVANCE
Expand All @@ -213,9 +213,9 @@ public function calculateChildrensDay()
$this->addHoliday(new Holiday(
'childrensDay',
[
'en_US' => 'International Children\'s Day',
'ro_RO' => 'Ziua Copilului'
],
'en_US' => 'International Children\'s Day',
'ro_RO' => 'Ziua Copilului'
],
new DateTime("$this->year-06-01", new DateTimeZone($this->timezone)),
$this->locale,
Holiday::TYPE_OBSERVANCE
Expand Down
Loading

0 comments on commit 36e422e

Please sign in to comment.