@@ -3,7 +3,7 @@ |
||
| 3 | 3 | namespace Jasny\Twig; |
| 4 | 4 | |
| 5 | 5 | |
| 6 | -class DateExtensionTest extends \PHPUnit_Framework_TestCase { |
|
| 6 | +class DateExtensionTest extends \PHPUnit_Framework_TestCase { |
|
| 7 | 7 | |
| 8 | 8 | public static function setUpBeforeClass() { |
| 9 | 9 | parent::setUpBeforeClass(); |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | namespace Jasny\Twig; |
| 4 | 4 | |
| 5 | 5 | |
| 6 | -class TextExtensionTest extends \PHPUnit_Framework_TestCase { |
|
| 6 | +class TextExtensionTest extends \PHPUnit_Framework_TestCase { |
|
| 7 | 7 | |
| 8 | 8 | private function buildEnv($template) { |
| 9 | 9 | $loader = new \Twig_Loader_Array(array( |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | namespace Jasny\Twig; |
| 4 | 4 | |
| 5 | 5 | |
| 6 | -class ArrayExtensionTest extends \PHPUnit_Framework_TestCase { |
|
| 6 | +class ArrayExtensionTest extends \PHPUnit_Framework_TestCase { |
|
| 7 | 7 | |
| 8 | 8 | private function buildEnv($template) { |
| 9 | 9 | $loader = new \Twig_Loader_Array(array( |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | namespace Jasny\Twig; |
| 4 | 4 | |
| 5 | 5 | |
| 6 | -class PcreExtensionTest extends \PHPUnit_Framework_TestCase { |
|
| 6 | +class PcreExtensionTest extends \PHPUnit_Framework_TestCase { |
|
| 7 | 7 | |
| 8 | 8 | private function buildEnv($template) { |
| 9 | 9 | $loader = new \Twig_Loader_Array(array( |
@@ -51,16 +51,16 @@ discard block |
||
| 51 | 51 | * @param int $calendar |
| 52 | 52 | * @return array(format, pattern) |
| 53 | 53 | */ |
| 54 | - protected function getFormat($format, $calendar=\IntlDateFormatter::GREGORIAN) |
|
| 54 | + protected function getFormat($format, $calendar = \IntlDateFormatter::GREGORIAN) |
|
| 55 | 55 | { |
| 56 | 56 | $pattern = null; |
| 57 | 57 | |
| 58 | 58 | switch ($format) { |
| 59 | 59 | case null: $format = \IntlDateFormatter::SHORT; $pattern = $this->getDefaultDatePattern($calendar); break; |
| 60 | - case 'short': $format = \IntlDateFormatter::SHORT; break; |
|
| 60 | + case 'short': $format = \IntlDateFormatter::SHORT; break; |
|
| 61 | 61 | case 'medium': $format = \IntlDateFormatter::MEDIUM; break; |
| 62 | - case 'long': $format = \IntlDateFormatter::LONG; break; |
|
| 63 | - case 'full': $format = \IntlDateFormatter::FULL; break; |
|
| 62 | + case 'long': $format = \IntlDateFormatter::LONG; break; |
|
| 63 | + case 'full': $format = \IntlDateFormatter::FULL; break; |
|
| 64 | 64 | default: $pattern = $format; $format = \IntlDateFormatter::SHORT; break; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param int $calendar |
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | - protected function getDefaultDatePattern($calendar=\IntlDateFormatter::GREGORIAN) |
|
| 76 | + protected function getDefaultDatePattern($calendar = \IntlDateFormatter::GREGORIAN) |
|
| 77 | 77 | { |
| 78 | 78 | return preg_replace('/\byy?\b/', 'yyyy', \IntlDateFormatter::create(\Locale::getDefault(), \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE, \IntlTimeZone::getGMT(), $calendar)->getPattern()); |
| 79 | 79 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param string $calendar 'gregorian' or 'traditional' |
| 87 | 87 | * @return string |
| 88 | 88 | */ |
| 89 | - public function localDate($date, $format=null, $calendar='gregorian') |
|
| 89 | + public function localDate($date, $format = null, $calendar = 'gregorian') |
|
| 90 | 90 | { |
| 91 | 91 | if (!isset($date)) return null; |
| 92 | 92 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @param string $calendar 'gregorian' or 'traditional' |
| 110 | 110 | * @return string |
| 111 | 111 | */ |
| 112 | - public function localTime($date, $format='short', $calendar='gregorian') |
|
| 112 | + public function localTime($date, $format = 'short', $calendar = 'gregorian') |
|
| 113 | 113 | { |
| 114 | 114 | if (!isset($date)) return null; |
| 115 | 115 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param string $calendar 'gregorian' or 'traditional' |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public function localDateTime($date, $format=null, $calendar='gregorian') |
|
| 135 | + public function localDateTime($date, $format = null, $calendar = 'gregorian') |
|
| 136 | 136 | { |
| 137 | 137 | if (!isset($date)) return null; |
| 138 | 138 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $format_time = 'short'; |
| 148 | 148 | |
| 149 | 149 | extract((array)$format, EXTR_PREFIX_ALL, 'format'); |
| 150 | - return $this->localDate($date, $format_date, $calendar) . ' ' . $this->localTime($date, $format_time, $calendar); |
|
| 150 | + return $this->localDate($date, $format_date, $calendar).' '.$this->localTime($date, $format_time, $calendar); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | list($format, $pattern) = $this->getFormat($format, $calendar); |
@@ -199,18 +199,18 @@ discard block |
||
| 199 | 199 | * @param string $separator |
| 200 | 200 | * @return string |
| 201 | 201 | */ |
| 202 | - public function duration($seconds, $units=array('s', 'm', 'h', 'd', 'w', 'y'), $seperator=' ') |
|
| 202 | + public function duration($seconds, $units = array('s', 'm', 'h', 'd', 'w', 'y'), $seperator = ' ') |
|
| 203 | 203 | { |
| 204 | 204 | list($seconds, $minutes, $hours, $days, $weeks, $years) = |
| 205 | - $this->splitDuration($seconds, count($units)-1) + array_fill(0, 6, null); |
|
| 205 | + $this->splitDuration($seconds, count($units) - 1) + array_fill(0, 6, null); |
|
| 206 | 206 | |
| 207 | 207 | $duration = ''; |
| 208 | - if (isset($years) && isset($units[5])) $duration .= $seperator . $years . $units[5]; |
|
| 209 | - if (isset($weeks) && isset($units[4])) $duration .= $seperator . $weeks . $units[4]; |
|
| 210 | - if (isset($days) && isset($units[3])) $duration .= $seperator . $days . $units[3]; |
|
| 211 | - if (isset($hours) && isset($units[2])) $duration .= $seperator . $hours . $units[2]; |
|
| 212 | - if (isset($minutes) && isset($units[1])) $duration .= $seperator . $minutes . $units[1]; |
|
| 213 | - if (isset($seconds) && isset($units[0])) $duration .= $seperator . $seconds . $units[0]; |
|
| 208 | + if (isset($years) && isset($units[5])) $duration .= $seperator.$years.$units[5]; |
|
| 209 | + if (isset($weeks) && isset($units[4])) $duration .= $seperator.$weeks.$units[4]; |
|
| 210 | + if (isset($days) && isset($units[3])) $duration .= $seperator.$days.$units[3]; |
|
| 211 | + if (isset($hours) && isset($units[2])) $duration .= $seperator.$hours.$units[2]; |
|
| 212 | + if (isset($minutes) && isset($units[1])) $duration .= $seperator.$minutes.$units[1]; |
|
| 213 | + if (isset($seconds) && isset($units[0])) $duration .= $seperator.$seconds.$units[0]; |
|
| 214 | 214 | |
| 215 | 215 | return trim($duration, $seperator); |
| 216 | 216 | } |