Skip to content

Commit

Permalink
PSR-2 fixes (causing Travis to fail).
Browse files Browse the repository at this point in the history
  • Loading branch information
stelgenhof committed Nov 25, 2016
1 parent a5d39d2 commit 53154a2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/Yasumi/Holiday.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,17 @@ public function __construct(
}

// Validate if date parameter is instance of DateTime
if ( ! ($date instanceof DateTime)) {
if (! ($date instanceof DateTime)) {
throw new InvalidArgumentException(sprintf('Date "%s" is not a valid DateTime instance.', $date));
}

// Load internal locales variable
if ( ! isset(static::$locales)) {
if (! isset(static::$locales)) {
static::$locales = Yasumi::getAvailableLocales();
}

// Assert display locale input
if ( ! in_array($displayLocale, static::$locales)) {
if (! in_array($displayLocale, static::$locales)) {
throw new UnknownLocaleException(sprintf('Locale "%s" is not a valid locale.', $displayLocale));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Yasumi/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function isHoliday($date)
}

// If given date is a Yasumi\Holiday object
if ( ! is_null($date) && in_array($date, $this->holidays)) {
if (! is_null($date) && in_array($date, $this->holidays)) {
return true;
}

Expand Down
16 changes: 8 additions & 8 deletions src/Yasumi/Provider/Japan.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private function calculateVernalEquinoxDay()
$day = null;
}

if ( ! is_null($day)) {
if (! is_null($day)) {
$this->addHoliday(new Holiday('vernalEquinoxDay', ['en_US' => 'Vernal Equinox Day', 'ja_JP' => '春分の日'],
new DateTime("$this->year-3-$day", new DateTimeZone($this->timezone)), $this->locale));
}
Expand All @@ -208,7 +208,7 @@ private function calculateComingOfAgeDay()
} elseif ($this->year >= 1948) {
$date = new DateTime("$this->year-1-15", new DateTimeZone($this->timezone));
}
if ( ! is_null($date)) {
if (! is_null($date)) {
$this->addHoliday(new Holiday('comingOfAgeDay', ['en_US' => 'Coming of Age Day', 'ja_JP' => '成人の日'], $date,
$this->locale));
}
Expand All @@ -227,7 +227,7 @@ private function calculateGreeneryDay()
} elseif ($this->year >= 1989) {
$date = new DateTime("$this->year-4-29", new DateTimeZone($this->timezone));
}
if ( ! is_null($date)) {
if (! is_null($date)) {
$this->addHoliday(new Holiday('greeneryDay', ['en_US' => 'Greenery Day', 'ja_JP' => '緑の日'], $date,
$this->locale));
}
Expand All @@ -246,7 +246,7 @@ private function calculateMarineDay()
} elseif ($this->year >= 1996) {
$date = new DateTime("$this->year-7-20", new DateTimeZone($this->timezone));
}
if ( ! is_null($date)) {
if (! is_null($date)) {
$this->addHoliday(new Holiday('marineDay', ['en_US' => 'Marine Day', 'ja_JP' => '海の日'], $date,
$this->locale));
}
Expand All @@ -266,7 +266,7 @@ private function calculateRespectForTheAgeDay()
} elseif ($this->year >= 1996) {
$date = new DateTime("$this->year-9-15", new DateTimeZone($this->timezone));
}
if ( ! is_null($date)) {
if (! is_null($date)) {
$this->addHoliday(new Holiday('respectfortheAgedDay',
['en_US' => 'Respect for the Aged Day', 'ja_JP' => '敬老の日'], $date, $this->locale));
}
Expand All @@ -286,7 +286,7 @@ private function calculateHealthAndSportsDay()
} elseif ($this->year >= 1996) {
$date = new DateTime("$this->year-10-10", new DateTimeZone($this->timezone));
}
if ( ! is_null($date)) {
if (! is_null($date)) {
$this->addHoliday(new Holiday('healthandSportsDay', ['en_US' => 'Health And Sports Day', 'ja_JP' => '体育の日'],
$date, $this->locale));
}
Expand Down Expand Up @@ -316,7 +316,7 @@ private function calculateAutumnalEquinoxDay()
$day = null;
}

if ( ! is_null($day)) {
if (! is_null($day)) {
$this->addHoliday(new Holiday('autumnalEquinoxDay', ['en_US' => 'Autumnal Equinox Day', 'ja_JP' => '秋分の日'],
new DateTime("$this->year-9-$day", new DateTimeZone($this->timezone)), $this->locale));
}
Expand Down Expand Up @@ -355,7 +355,7 @@ private function calculateSubstituteHolidays()
}

// Add a new holiday that is substituting the original holiday
if ( ! is_null($substituteDay)) {
if (! is_null($substituteDay)) {
$substituteHoliday = new Holiday('substituteHoliday:' . $shortName, [
'en_US' => $date->translations['en_US'] . ' Observed',
'ja_JP' => '振替休日 (' . $date->translations['ja_JP'] . ')',
Expand Down
12 changes: 6 additions & 6 deletions src/Yasumi/Translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct($availableLocales)
*/
public function loadTranslations($directoryPath)
{
if ( ! file_exists($directoryPath)) {
if (! file_exists($directoryPath)) {
throw new InvalidArgumentException('Directory with translations not found');
}

Expand Down Expand Up @@ -92,7 +92,7 @@ public function loadTranslations($directoryPath)
*/
protected function isValidLocale($locale)
{
if ( ! in_array($locale, $this->availableLocales)) {
if (! in_array($locale, $this->availableLocales)) {
throw new UnknownLocaleException(sprintf('Locale "%s" is not a valid locale.', $locale));
}

Expand All @@ -110,7 +110,7 @@ public function addTranslation($shortName, $locale, $translation)
{
$this->isValidLocale($locale); // Validate the given locale

if ( ! array_key_exists($shortName, $this->translations)) {
if (! array_key_exists($shortName, $this->translations)) {
$this->translations[$shortName] = [];
}

Expand All @@ -127,11 +127,11 @@ public function addTranslation($shortName, $locale, $translation)
*/
public function getTranslation($shortName, $locale)
{
if ( ! array_key_exists($shortName, $this->translations)) {
if (! array_key_exists($shortName, $this->translations)) {
return null;
}

if ( ! array_key_exists($locale, $this->translations[$shortName])) {
if (! array_key_exists($locale, $this->translations[$shortName])) {
return null;
}

Expand All @@ -147,7 +147,7 @@ public function getTranslation($shortName, $locale)
*/
public function getTranslations($shortName)
{
if ( ! array_key_exists($shortName, $this->translations)) {
if (! array_key_exists($shortName, $this->translations)) {
return [];
}

Expand Down
16 changes: 8 additions & 8 deletions src/Yasumi/Yasumi.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function getProviders()
public static function nextWorkingDay($class, $startDate, $workingDays = 1)
{
/* @TODO we should accept a timezone so we can accept int/string for $startDate */
if ( ! ($startDate instanceof DateTime)) {
if (! ($startDate instanceof DateTime)) {
throw new Exception('Bad parameter, DateTime expected');
}

Expand All @@ -119,7 +119,7 @@ public static function nextWorkingDay($class, $startDate, $workingDays = 1)

while ($workingDays > 0) {
$date->add(new DateInterval('P1D'));
if ( ! $provider || $provider->getYear() != $date->format('Y')) {
if (! $provider || $provider->getYear() != $date->format('Y')) {
$provider = self::create($class, $date->format('Y'));
}
if ($provider->isWorkingDay($date)) {
Expand Down Expand Up @@ -158,7 +158,7 @@ public static function create($class, $year = null, $locale = self::DEFAULT_LOCA
$providerClass = $class;
}

if ( ! class_exists($providerClass) || $class === 'AbstractProvider') {
if (! class_exists($providerClass) || $class === 'AbstractProvider') {
throw new InvalidArgumentException(sprintf('Unable to find holiday provider "%s".', $class));
}

Expand All @@ -168,18 +168,18 @@ public static function create($class, $year = null, $locale = self::DEFAULT_LOCA
}

// Load internal locales variable
if ( ! isset(static::$locales)) {
if (! isset(static::$locales)) {
static::$locales = self::getAvailableLocales();
}

// Load internal translations variable
if ( ! isset(static::$globalTranslations)) {
if (! isset(static::$globalTranslations)) {
static::$globalTranslations = new Translations(static::$locales);
static::$globalTranslations->loadTranslations(__DIR__ . '/data/translations');
}

// Assert locale input
if ( ! in_array($locale, static::$locales)) {
if (! in_array($locale, static::$locales)) {
throw new UnknownLocaleException(sprintf('Locale "%s" is not a valid locale.', $locale));
}

Expand Down Expand Up @@ -207,7 +207,7 @@ public static function getAvailableLocales()
public static function prevWorkingDay($class, $startDate, $workingDays = 1)
{
/* @TODO we should accept a timezone so we can accept int/string for $startDate */
if ( ! ($startDate instanceof DateTime)) {
if (! ($startDate instanceof DateTime)) {
throw new Exception('Bad parameter, DateTime expected');
}

Expand All @@ -218,7 +218,7 @@ public static function prevWorkingDay($class, $startDate, $workingDays = 1)

while ($workingDays > 0) {
$date->sub(new DateInterval('P1D'));
if ( ! $provider || $provider->getYear() != $date->format('Y')) {
if (! $provider || $provider->getYear() != $date->format('Y')) {
$provider = self::create($class, $date->format('Y'));
}
if ($provider->isWorkingDay($date)) {
Expand Down

0 comments on commit 53154a2

Please sign in to comment.