diff --git a/.travis.yml b/.travis.yml index f85e2f5..70d730f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: php php: - - 5.3.3 - - 5.3 - 5.4 - 5.5.9 - 5.5 diff --git a/composer.json b/composer.json index 892bd45..9ec3ddb 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,13 @@ } ], "require": { - "php": ">=5.3.3", + "php": ">=5.4", "nesbot/carbon": "^1.0", "symfony/translation": "^2.0|^3.0" }, "require-dev": { "phpunit/phpunit": "^4.0|^5.0", - "satooshi/php-coveralls": "^0.6" + "satooshi/php-coveralls": "^1.0" }, "autoload": { "psr-4": { diff --git a/src/Date.php b/src/Date.php index 8894f5f..d336554 100644 --- a/src/Date.php +++ b/src/Date.php @@ -8,8 +8,8 @@ use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\TranslatorInterface; -class Date extends Carbon { - +class Date extends Carbon +{ /** * The Translator implementation. * @@ -33,20 +33,16 @@ class Date extends Carbon { */ public function __construct($time = null, $timezone = null) { - if (is_int($time)) - { + if (is_int($time)) { $timestamp = $time; $time = null; - } - else - { + } else { $timestamp = null; } parent::__construct($time, $timezone); - if ($timestamp !== null) - { + if ($timestamp !== null) { $this->setTimestamp($timestamp); } } @@ -108,22 +104,21 @@ public function diffForHumans(Carbon $since = null, $absolute = false) // Are we comparing against another date? $relative = ! is_null($since); - if (is_null($since)) - { + if (is_null($since)) { $since = new static('now', $this->getTimezone()); } // Are we comparing to a date in the future? $future = $since->getTimestamp() < $this->getTimestamp(); - $units = array( + $units = [ 'second' => 60, 'minute' => 60, 'hour' => 24, 'day' => 7, 'week' => 30 / 7, 'month' => 12, - ); + ]; // Date difference $difference = abs($since->getTimestamp() - $this->getTimestamp()); @@ -132,10 +127,8 @@ public function diffForHumans(Carbon $since = null, $absolute = false) $unit = 'year'; // Select the best unit. - foreach ($units as $key => $value) - { - if ($difference < $value) - { + foreach ($units as $key => $value) { + if ($difference < $value) { $unit = $key; break; } @@ -146,37 +139,28 @@ public function diffForHumans(Carbon $since = null, $absolute = false) $difference = floor($difference); // Select the suffix. - if ($relative) - { + if ($relative) { $suffix = $future ? 'after' : 'before'; - } - else - { + } else { $suffix = $future ? 'from_now' : 'ago'; } // Some languages have different unit translations when used in combination // with a specific suffix. Here we will check if there is an optional // translation for that specific suffix and use it if it exists. - if ($lang->trans("${unit}_diff") != "${unit}_diff") - { - $ago = $lang->transChoice("${unit}_diff", $difference, array(':count' => $difference)); - } - elseif ($lang->trans("${unit}_${suffix}") != "${unit}_${suffix}") - { - $ago = $lang->transChoice("${unit}_${suffix}", $difference, array(':count' => $difference)); - } - else - { - $ago = $lang->transChoice($unit, $difference, array(':count' => $difference)); + if ($lang->trans("${unit}_diff") != "${unit}_diff") { + $ago = $lang->transChoice("${unit}_diff", $difference, [':count' => $difference]); + } elseif ($lang->trans("${unit}_${suffix}") != "${unit}_${suffix}") { + $ago = $lang->transChoice("${unit}_${suffix}", $difference, [':count' => $difference]); + } else { + $ago = $lang->transChoice($unit, $difference, [':count' => $difference]); } - if ($absolute) - { + if ($absolute) { return $ago; } - return $lang->transChoice($suffix, $difference, array(':time' => $ago)); + return $lang->transChoice($suffix, $difference, [':time' => $ago]); } /** @@ -210,21 +194,20 @@ public function until($since = null) */ public function format($format) { - $replace = array(); + $replace = []; // Loop all format characters and check if we can translate them. - for ($i = 0; $i < strlen($format); $i++) - { + for ($i = 0; $i < strlen($format); $i++) { $character = $format[$i]; // Check if we can replace it with a translated version. - if (in_array($character, array('D', 'l', 'F', 'M'))) - { + if (in_array($character, ['D', 'l', 'F', 'M'])) { // Check escaped characters. - if ($i > 0 and $format[$i - 1] == '\\') continue; + if ($i > 0 and $format[$i - 1] == '\\') { + continue; + } - switch ($character) - { + switch ($character) { case 'D': $key = parent::format('l'); break; @@ -243,31 +226,28 @@ public function format($format) // For declension support, we need to check if the month is lead by a numeric number. // If so, we will use the second translation choice if it is available. - if (in_array($character, array('F', 'M'))) - { - $choice = (($i - 2) >= 0 and in_array($format[$i - 2], array('d', 'j'))) ? 1 : 0; + if (in_array($character, ['F', 'M'])) { + $choice = (($i - 2) >= 0 and in_array($format[$i - 2], ['d', 'j'])) ? 1 : 0; $translated = $lang->transChoice(strtolower($key), $choice); - } - else - { + } else { $translated = $lang->trans(strtolower($key)); } // Short notations. - if (in_array($character, array('D', 'M'))) - { + if (in_array($character, ['D', 'M'])) { $translated = mb_substr($translated, 0, 3); } // Add to replace list. - if ($translated and $original != $translated) $replace[$original] = $translated; + if ($translated and $original != $translated) { + $replace[$original] = $translated; + } } } // Replace translations. - if ($replace) - { + if ($replace) { return str_replace(array_keys($replace), array_values($replace), parent::format($format)); } @@ -287,12 +267,11 @@ public function timespan($time = null, $timezone = null) $lang = $this->getTranslator(); // Create Date instance if needed - if ( ! $time instanceof Date) - { + if (! $time instanceof self) { $time = new static($time, $timezone); } - $units = array('y' => 'year', 'm' => 'month', 'w' => 'week', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', 's' => 'second'); + $units = ['y' => 'year', 'm' => 'month', 'w' => 'week', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', 's' => 'second']; // Get DateInterval and cast to array $interval = (array) $this->diff($time); @@ -302,12 +281,13 @@ public function timespan($time = null, $timezone = null) $interval['d'] = $interval['d'] % 7; // Get ready to build - $str = array(); + $str = []; // Loop all units and build string - foreach ($units as $k => $unit) - { - if ($interval[$k]) $str[] = $lang->transChoice($unit, $interval[$k], array(':count' => $interval[$k])); + foreach ($units as $k => $unit) { + if ($interval[$k]) { + $str[] = $lang->transChoice($unit, $interval[$k], [':count' => $interval[$k]]); + } } return implode(', ', $str); @@ -321,15 +301,11 @@ public function timespan($time = null, $timezone = null) */ public function add($interval) { - if (is_string($interval)) - { + if (is_string($interval)) { // Check for ISO 8601 - if (strtoupper(substr($interval, 0, 1)) == 'P') - { + if (strtoupper(substr($interval, 0, 1)) == 'P') { $interval = new DateInterval($interval); - } - else - { + } else { $interval = DateInterval::createFromDateString($interval); } } @@ -345,15 +321,11 @@ public function add($interval) */ public function sub($interval) { - if (is_string($interval)) - { + if (is_string($interval)) { // Check for ISO 8601 - if (strtoupper(substr($interval, 0, 1)) == 'P') - { + if (strtoupper(substr($interval, 0, 1)) == 'P') { $interval = new DateInterval($interval); - } - else - { + } else { $interval = DateInterval::createFromDateString($interval); } } @@ -382,9 +354,9 @@ public static function setLocale($locale) // Use RFC 5646 for filenames. $resource = __DIR__ . '/Lang/' . str_replace('_', '-', $locale) . '.php'; - if (! file_exists($resource)) - { + if (! file_exists($resource)) { static::setLocale(static::getFallbackLocale()); + return; } @@ -425,8 +397,7 @@ public static function getFallbackLocale() */ public static function getTranslator() { - if (static::$translator === null) - { + if (static::$translator === null) { static::$translator = new Translator('en'); static::$translator->addLoader('array', new ArrayLoader()); static::setLocale('en'); @@ -454,13 +425,12 @@ public static function setTranslator(TranslatorInterface $translator) public static function translateTimeString($time) { // Don't run translations for english. - if (static::getLocale() == 'en') - { + if (static::getLocale() == 'en') { return $time; } // All the language file items we can translate. - $keys = array('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); + $keys = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']; // Get all the language lines of the current locale. $all = static::getTranslator()->getCatalogue()->all(); @@ -470,5 +440,4 @@ public static function translateTimeString($time) // Replace the translated words with the English words return str_ireplace($lines, array_keys($lines), $time); } - } diff --git a/src/DateServiceProvider.php b/src/DateServiceProvider.php index 00295e7..9a8b5db 100644 --- a/src/DateServiceProvider.php +++ b/src/DateServiceProvider.php @@ -2,8 +2,8 @@ use Illuminate\Support\ServiceProvider; -class DateServiceProvider extends ServiceProvider { - +class DateServiceProvider extends ServiceProvider +{ /** * Indicates if loading of the provider is deferred. * @@ -40,7 +40,6 @@ public function register() */ public function provides() { - return array('Date'); + return ['Date']; } - } diff --git a/src/Lang/ar.php b/src/Lang/ar.php index 1478267..96fdc50 100644 --- a/src/Lang/ar.php +++ b/src/Lang/ar.php @@ -1,6 +1,6 @@ 'السبت', 'sunday' => 'الأحد', -); +]; diff --git a/src/Lang/az.php b/src/Lang/az.php index 70f942f..c2513b7 100644 --- a/src/Lang/az.php +++ b/src/Lang/az.php @@ -1,6 +1,6 @@ 'Şənbə', 'sunday' => 'Bazar', -); +]; diff --git a/src/Lang/bg.php b/src/Lang/bg.php index 73c7c5a..3867370 100644 --- a/src/Lang/bg.php +++ b/src/Lang/bg.php @@ -1,6 +1,16 @@ 'преди :time', 'from_now' => ':time от сега', @@ -35,4 +45,4 @@ 'saturday' => 'събота', 'sunday' => 'неделя', -); +]; diff --git a/src/Lang/ca.php b/src/Lang/ca.php index 02e7806..ad6531b 100644 --- a/src/Lang/ca.php +++ b/src/Lang/ca.php @@ -1,6 +1,6 @@ 'dissabte', 'sunday' => 'diumenge', -); +]; diff --git a/src/Lang/cs.php b/src/Lang/cs.php index 6627fda..f263e88 100644 --- a/src/Lang/cs.php +++ b/src/Lang/cs.php @@ -1,6 +1,6 @@ 'hodinou|[2,Inf]:count hodinami', 'minute_ago' => 'minutou|[2,Inf]:count minutami', 'second_ago' => '{0}0 sekundami|{1}sekundou|[2,Inf]:count sekundami', -); +]; diff --git a/src/Lang/da.php b/src/Lang/da.php index 3892675..a2b6531 100644 --- a/src/Lang/da.php +++ b/src/Lang/da.php @@ -1,6 +1,6 @@ 'lørdag', 'sunday' => 'søndag', -); +]; diff --git a/src/Lang/de.php b/src/Lang/de.php index 50c742b..f347da9 100644 --- a/src/Lang/de.php +++ b/src/Lang/de.php @@ -1,6 +1,6 @@ '1 Minute|:count Minuten', 'second_diff' => '1 Sekunde|:count Sekunden', -); +]; diff --git a/src/Lang/el.php b/src/Lang/el.php index 624c149..0c28e6c 100644 --- a/src/Lang/el.php +++ b/src/Lang/el.php @@ -1,6 +1,6 @@ 'Κυριακή', 'am' => 'πμ', - 'pm' => 'μμ' + 'pm' => 'μμ', -); +]; diff --git a/src/Lang/en.php b/src/Lang/en.php index 58021b1..79259cb 100644 --- a/src/Lang/en.php +++ b/src/Lang/en.php @@ -1,6 +1,6 @@ 'Saturday', 'sunday' => 'Sunday', -); +]; diff --git a/src/Lang/eo.php b/src/Lang/eo.php index 23f59ba..b2ecb2c 100644 --- a/src/Lang/eo.php +++ b/src/Lang/eo.php @@ -1,6 +1,6 @@ 'sabato', 'sunday' => 'dimanĉo', -); +]; diff --git a/src/Lang/es.php b/src/Lang/es.php index 2043051..e60bf3c 100644 --- a/src/Lang/es.php +++ b/src/Lang/es.php @@ -1,6 +1,6 @@ 'sábado', 'sunday' => 'domingo', -); +]; diff --git a/src/Lang/et.php b/src/Lang/et.php index 0272440..a2a5a1f 100644 --- a/src/Lang/et.php +++ b/src/Lang/et.php @@ -1,6 +1,6 @@ ':time tagasi', 'from_now' => 'alates :time', @@ -33,5 +33,5 @@ 'thursday' => 'neljapäev', 'friday' => 'reede', 'saturday' => 'laupäev', - 'sunday' => 'pühapäev' -); + 'sunday' => 'pühapäev', +]; diff --git a/src/Lang/eu.php b/src/Lang/eu.php index 5ad6864..bb7342d 100644 --- a/src/Lang/eu.php +++ b/src/Lang/eu.php @@ -1,6 +1,6 @@ 'Larunbata', 'sunday' => 'Igandea', -); +]; diff --git a/src/Lang/fa.php b/src/Lang/fa.php index 131eeff..581216f 100644 --- a/src/Lang/fa.php +++ b/src/Lang/fa.php @@ -1,13 +1,16 @@ ':time پیش', 'from_now' => ':time از الآن', @@ -42,4 +45,4 @@ 'saturday' => 'شنبه', 'sunday' => 'یک‌شنبه', -); +]; diff --git a/src/Lang/fi.php b/src/Lang/fi.php index 70af67f..02dcf51 100644 --- a/src/Lang/fi.php +++ b/src/Lang/fi.php @@ -1,6 +1,6 @@ 'lauantai', 'sunday' => 'sunnuntai', -); +]; diff --git a/src/Lang/fr.php b/src/Lang/fr.php index 6a9a920..b40a959 100644 --- a/src/Lang/fr.php +++ b/src/Lang/fr.php @@ -1,6 +1,6 @@ 'samedi', 'sunday' => 'dimanche', -); +]; diff --git a/src/Lang/he.php b/src/Lang/he.php index dcb24c9..aab5620 100644 --- a/src/Lang/he.php +++ b/src/Lang/he.php @@ -1,6 +1,6 @@ 'שבת', 'sunday' => 'ראשון', -); +]; diff --git a/src/Lang/hi.php b/src/Lang/hi.php index 9b472cc..c7850dd 100644 --- a/src/Lang/hi.php +++ b/src/Lang/hi.php @@ -1,6 +1,6 @@ 'शनिवार', 'sunday' => 'रविवार', -); +]; diff --git a/src/Lang/hr.php b/src/Lang/hr.php index 4e7e4fe..a6c6a94 100644 --- a/src/Lang/hr.php +++ b/src/Lang/hr.php @@ -1,6 +1,6 @@ 'subota', 'sunday' => 'nedjelja', -); +]; diff --git a/src/Lang/hu.php b/src/Lang/hu.php index 4722aea..e434218 100644 --- a/src/Lang/hu.php +++ b/src/Lang/hu.php @@ -1,6 +1,6 @@ 'szombat', 'sunday' => 'vasárnap', -); +]; diff --git a/src/Lang/id.php b/src/Lang/id.php index ee855ee..168245a 100644 --- a/src/Lang/id.php +++ b/src/Lang/id.php @@ -1,6 +1,6 @@ 'Sabtu', 'sunday' => 'Minggu', -); +]; diff --git a/src/Lang/is.php b/src/Lang/is.php index 09f3ee4..12a0843 100644 --- a/src/Lang/is.php +++ b/src/Lang/is.php @@ -1,6 +1,6 @@ 'laugardagur', 'sunday' => 'sunnudagur', -); +]; diff --git a/src/Lang/it.php b/src/Lang/it.php index e1fc5d2..3cf89c5 100644 --- a/src/Lang/it.php +++ b/src/Lang/it.php @@ -1,6 +1,6 @@ 'sabato', 'sunday' => 'domenica', -); +]; diff --git a/src/Lang/ja.php b/src/Lang/ja.php index 49f3bd6..317334b 100644 --- a/src/Lang/ja.php +++ b/src/Lang/ja.php @@ -1,6 +1,6 @@ '土曜日', 'sunday' => '日曜日', -); +]; diff --git a/src/Lang/ka.php b/src/Lang/ka.php index 06185bc..82cb568 100644 --- a/src/Lang/ka.php +++ b/src/Lang/ka.php @@ -1,12 +1,6 @@ - * @version 1.0.0 - */ -return array( +return [ /* |-------------------------------------------------------------------------- @@ -51,4 +45,4 @@ 'saturday' => 'შაბათი', 'sunday' => 'კვირა', -); +]; diff --git a/src/Lang/ko.php b/src/Lang/ko.php index 24484f9..a8b3bf4 100644 --- a/src/Lang/ko.php +++ b/src/Lang/ko.php @@ -1,6 +1,6 @@ '토요일', 'sunday' => '일요일', -); +]; diff --git a/src/Lang/lv.php b/src/Lang/lv.php index 08a90bd..a429945 100644 --- a/src/Lang/lv.php +++ b/src/Lang/lv.php @@ -1,6 +1,6 @@ 'Sestdiena', 'sunday' => 'Svētdiena', -); +]; diff --git a/src/Lang/mk.php b/src/Lang/mk.php index 479bd07..f839af4 100644 --- a/src/Lang/mk.php +++ b/src/Lang/mk.php @@ -1,6 +1,16 @@ 'пред :time', 'from_now' => 'за :time', @@ -35,4 +45,4 @@ 'saturday' => 'сабота', 'sunday' => 'недела', -); +]; diff --git a/src/Lang/ms.php b/src/Lang/ms.php index 51a50a9..22bd364 100644 --- a/src/Lang/ms.php +++ b/src/Lang/ms.php @@ -1,6 +1,6 @@ 'Sabtu', 'sunday' => 'Ahad', -); +]; diff --git a/src/Lang/nl.php b/src/Lang/nl.php index eff1597..76cbcef 100644 --- a/src/Lang/nl.php +++ b/src/Lang/nl.php @@ -1,6 +1,6 @@ 'zaterdag', 'sunday' => 'zondag', -); +]; diff --git a/src/Lang/no.php b/src/Lang/no.php index 38cbd6b..885174b 100644 --- a/src/Lang/no.php +++ b/src/Lang/no.php @@ -1,6 +1,6 @@ 'lørdag', 'sunday' => 'søndag', -); +]; diff --git a/src/Lang/pl.php b/src/Lang/pl.php index 745d0de..db1210b 100644 --- a/src/Lang/pl.php +++ b/src/Lang/pl.php @@ -1,6 +1,6 @@ 'sobota', 'sunday' => 'niedziela', -); +]; diff --git a/src/Lang/pt-BR.php b/src/Lang/pt-BR.php index d691761..7c072e6 100644 --- a/src/Lang/pt-BR.php +++ b/src/Lang/pt-BR.php @@ -1,6 +1,6 @@ 'sábado', 'sunday' => 'domingo', -); +]; diff --git a/src/Lang/pt.php b/src/Lang/pt.php index 2b1d89d..7fef2ee 100644 --- a/src/Lang/pt.php +++ b/src/Lang/pt.php @@ -1,6 +1,6 @@ 'sábado', 'sunday' => 'domingo', -); +]; diff --git a/src/Lang/ro.php b/src/Lang/ro.php index c4f9c54..3892b4e 100644 --- a/src/Lang/ro.php +++ b/src/Lang/ro.php @@ -1,6 +1,6 @@ 'sâmbătă', 'sunday' => 'duminică', -); +]; diff --git a/src/Lang/ru.php b/src/Lang/ru.php index e71e29d..4becbdd 100644 --- a/src/Lang/ru.php +++ b/src/Lang/ru.php @@ -1,6 +1,6 @@ 'суббота', 'sunday' => 'воскресенье', -); +]; diff --git a/src/Lang/sh.php b/src/Lang/sh.php index 9611613..f69140e 100644 --- a/src/Lang/sh.php +++ b/src/Lang/sh.php @@ -1,6 +1,6 @@ 'subota', 'sunday' => 'nedelja', -); +]; diff --git a/src/Lang/sk.php b/src/Lang/sk.php index bd4f2c1..c92823f 100644 --- a/src/Lang/sk.php +++ b/src/Lang/sk.php @@ -1,6 +1,6 @@ 'minútou|[2,Inf]:count minútami', 'second_ago' => '{0}0 sekundami|{1}sekundou|[2,Inf]:count sekundami', -); +]; diff --git a/src/Lang/sl.php b/src/Lang/sl.php index c6ac25a..d501aa8 100644 --- a/src/Lang/sl.php +++ b/src/Lang/sl.php @@ -1,6 +1,6 @@ 'sobota', 'sunday' => 'nedelja', -); +]; diff --git a/src/Lang/sq.php b/src/Lang/sq.php index f69516a..13a2828 100644 --- a/src/Lang/sq.php +++ b/src/Lang/sq.php @@ -1,6 +1,6 @@ 'E Shtunë', 'sunday' => 'E Diel', -); +]; diff --git a/src/Lang/sr.php b/src/Lang/sr.php index 662796d..d7f14b2 100644 --- a/src/Lang/sr.php +++ b/src/Lang/sr.php @@ -1,6 +1,6 @@ 'субота', 'sunday' => 'недеља', -); +]; diff --git a/src/Lang/sv.php b/src/Lang/sv.php index c417a32..8687c41 100644 --- a/src/Lang/sv.php +++ b/src/Lang/sv.php @@ -1,6 +1,6 @@ 'lördag', 'sunday' => 'söndag', -); +]; diff --git a/src/Lang/th.php b/src/Lang/th.php index bce8694..4a99c3c 100644 --- a/src/Lang/th.php +++ b/src/Lang/th.php @@ -1,6 +1,6 @@ 'เสาร์', 'sunday' => 'อาทิตย์', -); +]; diff --git a/src/Lang/tk.php b/src/Lang/tk.php index d0ac938..1bb296d 100644 --- a/src/Lang/tk.php +++ b/src/Lang/tk.php @@ -1,6 +1,6 @@ 'Şenbe', 'sunday' => 'Ýekşenbe', -); +]; diff --git a/src/Lang/tr.php b/src/Lang/tr.php index 6bd4343..edf4a49 100644 --- a/src/Lang/tr.php +++ b/src/Lang/tr.php @@ -1,6 +1,6 @@ 'Cumartesi', 'sunday' => 'Pazar', -); +]; diff --git a/src/Lang/uk.php b/src/Lang/uk.php index 9f62aa5..5d455d6 100644 --- a/src/Lang/uk.php +++ b/src/Lang/uk.php @@ -1,6 +1,6 @@ 'субота', 'sunday' => 'неділя', -); +]; diff --git a/src/Lang/vi.php b/src/Lang/vi.php index d4d4841..d38bbf7 100644 --- a/src/Lang/vi.php +++ b/src/Lang/vi.php @@ -1,6 +1,6 @@ 'Thứ bảy', 'sunday' => 'Chủ nhật', -); +]; diff --git a/src/Lang/zh-CN.php b/src/Lang/zh-CN.php index ab7c027..5da21d6 100644 --- a/src/Lang/zh-CN.php +++ b/src/Lang/zh-CN.php @@ -1,6 +1,6 @@ '星期六', 'sunday' => '星期日', -); +]; diff --git a/src/Lang/zh-TW.php b/src/Lang/zh-TW.php index 1ed4104..b4fb5b8 100644 --- a/src/Lang/zh-TW.php +++ b/src/Lang/zh-TW.php @@ -1,6 +1,6 @@ '星期六', 'sunday' => '星期日', -); +]; diff --git a/src/Lang/zh.php b/src/Lang/zh.php index ab7c027..5da21d6 100644 --- a/src/Lang/zh.php +++ b/src/Lang/zh.php @@ -1,6 +1,6 @@ '星期六', 'sunday' => '星期日', -); +]; diff --git a/tests/AutomaticTest.php b/tests/AutomaticTest.php index a30084e..7bf497a 100644 --- a/tests/AutomaticTest.php +++ b/tests/AutomaticTest.php @@ -3,8 +3,8 @@ use Jenssegers\Date\Date; use Symfony\Component\Translation\MessageSelector; -class AutomaticTest extends PHPUnit_Framework_TestCase { - +class AutomaticTest extends PHPUnit_Framework_TestCase +{ public function setUp() { $this->languages = array_slice(scandir('src/Lang'), 2); @@ -29,13 +29,11 @@ public function testTranslatesMonths() $selector = new MessageSelector; - foreach ($this->languages as $language) - { + foreach ($this->languages as $language) { $language = str_replace('.php', '', $language); $translations = include "src/Lang/$language.php"; - foreach ($months as $month) - { + foreach ($months as $month) { $date = new Date("1 $month"); $date->setLocale($language); @@ -60,13 +58,11 @@ public function testTranslatesDays() 'sunday', ); - foreach ($this->languages as $language) - { + foreach ($this->languages as $language) { $language = str_replace('.php', '', $language); $translations = include "src/Lang/$language.php"; - foreach ($days as $day) - { + foreach ($days as $day) { $date = new Date($day); $date->setLocale($language); @@ -93,27 +89,21 @@ public function testTranslatesDiffForHumans() 'second', ); - foreach ($this->languages as $language) - { + foreach ($this->languages as $language) { $language = str_replace('.php', '', $language); $translations = include "src/Lang/$language.php"; - foreach ($items as $item) - { + foreach ($items as $item) { $this->assertTrue(isset($translations[$item]), "Language: $language >> $item"); - if ( ! $translations[$item]) - { + if (! $translations[$item]) { echo "\nWARNING! '$item' not set for language $language"; continue; } - if (in_array($item, array('ago', 'from_now', 'after', 'before'))) - { + if (in_array($item, array('ago', 'from_now', 'after', 'before'))) { $this->assertContains(':time', $translations[$item], "Language: $language"); - } - else - { + } else { $this->assertContains(':count', $translations[$item], "Language: $language"); } } @@ -136,35 +126,27 @@ public function testTranslatesCounts() 'second', ); - foreach ($this->languages as $language) - { - + foreach ($this->languages as $language) { $language = str_replace('.php', '', $language); $translations = include "src/Lang/$language.php"; $translator = Date::getTranslator(); $translator->setLocale($language); - foreach ($items as $item) - { + foreach ($items as $item) { $this->assertTrue(isset($translations[$item]), "Language: $language >> $item"); - if ( ! $translations[$item]) - { + if (! $translations[$item]) { echo "\nWARNING! '$item' not set for language $language\n"; continue; } - for ($i = 0; $i <= 60; $i++) - { - if (in_array($item, array('ago', 'from_now', 'after', 'before'))) - { + for ($i = 0; $i <= 60; $i++) { + if (in_array($item, array('ago', 'from_now', 'after', 'before'))) { $translation = $translator->transChoice($item, $i, array(':time' => $i)); $this->assertNotNull($translation, "Language: $language ($i)"); $this->assertNotContains(':time', $translation, "Language: $language ($i)"); - } - else - { + } else { $translation = $translator->transChoice($item, $i, array(':count' => $i)); $this->assertNotNull($translation, "Language: $language ($i)"); $this->assertNotContains(':count', $translation, "Language: $language ($i)"); @@ -173,5 +155,4 @@ public function testTranslatesCounts() } } } - } diff --git a/tests/DateTest.php b/tests/DateTest.php index a22c335..f62d479 100644 --- a/tests/DateTest.php +++ b/tests/DateTest.php @@ -2,8 +2,8 @@ use Jenssegers\Date\Date; -class DateTest extends PHPUnit_Framework_TestCase { - +class DateTest extends PHPUnit_Framework_TestCase +{ public function setUp() { date_default_timezone_set('UTC'); @@ -153,5 +153,4 @@ public function testTimespan() $this->assertSame('3 months, 1 week, 1 day, 3 hours, 20 minutes', $date->timespan(1403619368)); } - } diff --git a/tests/TranslationKaTest.php b/tests/TranslationKaTest.php index 25d81ed..bcb4ef0 100644 --- a/tests/TranslationKaTest.php +++ b/tests/TranslationKaTest.php @@ -1,12 +1,9 @@ assertSame('10 წლის შემდეგ', $date->ago(Date::now())); } - }