Completed
Push — master ( 205cf7...842449 )
by Arnold
02:56
created
src/DateExtension.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -183,6 +183,7 @@  discard block
 block discarded – undo
183 183
      * Split duration into seconds, minutes, hours, days, weeks and years.
184 184
      * 
185 185
      * @param int $seconds
186
+     * @param integer $max
186 187
      * @return array
187 188
      */
188 189
     protected function splitDuration($seconds, $max)
@@ -228,7 +229,7 @@  discard block
 block discarded – undo
228 229
      * 
229 230
      * @param int    $seconds    Time in seconds
230 231
      * @param array  $units      Time units (seconds, minutes, hours, days, weeks, years)
231
-     * @param string $separator
232
+     * @param string $seperator
232 233
      * @return string
233 234
      */
234 235
     public function duration($seconds, $units = ['s', 'm', 'h', 'd', 'w', 'y'], $seperator = ' ')
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,13 +62,13 @@
 block discarded – undo
62 62
         
63 63
         switch ($format) {
64 64
             case null:     $pattern = $this->getDefaultDatePattern($calendar); 
65
-                           $format = \IntlDateFormatter::SHORT; break;
65
+                            $format = \IntlDateFormatter::SHORT; break;
66 66
             case 'short':  $format = \IntlDateFormatter::SHORT;  break;
67 67
             case 'medium': $format = \IntlDateFormatter::MEDIUM; break;
68 68
             case 'long':   $format = \IntlDateFormatter::LONG;   break;
69 69
             case 'full':   $format = \IntlDateFormatter::FULL;   break;
70 70
             default:       $pattern = $format;
71
-                           $format = \IntlDateFormatter::SHORT; break;
71
+                            $format = \IntlDateFormatter::SHORT; break;
72 72
         }
73 73
         
74 74
         return [$format, $pattern];
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
         switch ($format) {
64 64
             case null:     $pattern = $this->getDefaultDatePattern($calendar); 
65 65
                            $format = \IntlDateFormatter::SHORT; break;
66
-            case 'short':  $format = \IntlDateFormatter::SHORT;  break;
66
+            case 'short':  $format = \IntlDateFormatter::SHORT; break;
67 67
             case 'medium': $format = \IntlDateFormatter::MEDIUM; break;
68
-            case 'long':   $format = \IntlDateFormatter::LONG;   break;
69
-            case 'full':   $format = \IntlDateFormatter::FULL;   break;
68
+            case 'long':   $format = \IntlDateFormatter::LONG; break;
69
+            case 'full':   $format = \IntlDateFormatter::FULL; break;
70 70
             default:       $pattern = $format;
71 71
                            $format = \IntlDateFormatter::SHORT; break;
72 72
         }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      * @param int $calendar
81 81
      * @return string
82 82
      */
83
-    protected function getDefaultDatePattern($calendar=\IntlDateFormatter::GREGORIAN)
83
+    protected function getDefaultDatePattern($calendar = \IntlDateFormatter::GREGORIAN)
84 84
     {
85 85
         $pattern = \IntlDateFormatter::create(
86 86
             \Locale::getDefault(),
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      * @param string              $calendar  'gregorian' or 'traditional'
151 151
      * @return string
152 152
      */
153
-    public function localTime($date, $format='short', $calendar='gregorian')
153
+    public function localTime($date, $format = 'short', $calendar = 'gregorian')
154 154
     {
155 155
         return $this->formatLocal($date, false, $format, $calendar);
156 156
     }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      * @param string              $calendar  'gregorian' or 'traditional'
164 164
      * @return string
165 165
      */
166
-    public function localDateTime($date, $format=null, $calendar='gregorian')
166
+    public function localDateTime($date, $format = null, $calendar = 'gregorian')
167 167
     {
168 168
         if (is_array($format) || !isset($format)) {
169 169
             $formatDate = null;
@@ -234,31 +234,31 @@  discard block
 block discarded – undo
234 234
     public function duration($seconds, $units = ['s', 'm', 'h', 'd', 'w', 'y'], $seperator = ' ')
235 235
     {
236 236
         list($seconds, $minutes, $hours, $days, $weeks, $years) =
237
-            $this->splitDuration($seconds, count($units)-1) + array_fill(0, 6, null);
237
+            $this->splitDuration($seconds, count($units) - 1) + array_fill(0, 6, null);
238 238
         
239 239
         $duration = '';
240 240
         if (isset($years) && isset($units[5])) {
241
-            $duration .= $seperator . $years . $units[5];
241
+            $duration .= $seperator.$years.$units[5];
242 242
         }
243 243
         
244 244
         if (isset($weeks) && isset($units[4])) {
245
-            $duration .= $seperator . $weeks . $units[4];
245
+            $duration .= $seperator.$weeks.$units[4];
246 246
         }
247 247
         
248 248
         if (isset($days) && isset($units[3])) {
249
-            $duration .= $seperator . $days . $units[3];
249
+            $duration .= $seperator.$days.$units[3];
250 250
         }
251 251
         
252 252
         if (isset($hours) && isset($units[2])) {
253
-            $duration .= $seperator . $hours . $units[2];
253
+            $duration .= $seperator.$hours.$units[2];
254 254
         }
255 255
         
256 256
         if (isset($minutes) && isset($units[1])) {
257
-            $duration .= $seperator . $minutes . $units[1];
257
+            $duration .= $seperator.$minutes.$units[1];
258 258
         }
259 259
         
260 260
         if (isset($seconds) && isset($units[0])) {
261
-            $duration .= $seperator . $seconds . $units[0];
261
+            $duration .= $seperator.$seconds.$units[0];
262 262
         }
263 263
         
264 264
         return trim($duration, $seperator);
Please login to merge, or discard this patch.
tests/TextExtensionTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -160,6 +160,6 @@
 block discarded – undo
160 160
      */
161 161
     public function testWithNull($filter)
162 162
     {
163
-        $this->assertRender('-', '{{ null|' . $filter . '("//")|default("-") }}');
163
+        $this->assertRender('-', '{{ null|'.$filter.'("//")|default("-") }}');
164 164
     }    
165 165
 }
Please login to merge, or discard this patch.
tests/PcreExtensionTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -172,6 +172,6 @@
 block discarded – undo
172 172
      */
173 173
     public function testWithNull($filter)
174 174
     {
175
-        $this->assertRender('-', '{{ null|' . $filter . '("//")|default("-") }}');
175
+        $this->assertRender('-', '{{ null|'.$filter.'("//")|default("-") }}');
176 176
     }    
177 177
 }
Please login to merge, or discard this patch.
tests/ArrayExtensionTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
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(
Please login to merge, or discard this patch.
src/TextExtension.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             return null;
44 44
         }
45 45
         
46
-        return '<p>' . preg_replace(['~\n(\s*)\n\s*~', '~(?<!</p>)\n\s*~'], ["</p>\n\$1<p>", "<br>\n"], trim($value)) .
46
+        return '<p>'.preg_replace(['~\n(\s*)\n\s*~', '~(?<!</p>)\n\s*~'], ["</p>\n\$1<p>", "<br>\n"], trim($value)).
47 47
             '</p>';
48 48
     }
49 49
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         }
81 81
         
82 82
         $pos = stripos($value, $break);
83
-        return $pos === false ? $value : substr($value, 0, $pos) . $replace;
83
+        return $pos === false ? $value : substr($value, 0, $pos).$replace;
84 84
     }
85 85
 
86 86
     /**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             return null;
98 98
         }
99 99
         
100
-        return strlen($value) <= $length ? $value : substr($value, 0, $length - strip_tags($replace)) . $replace;
100
+        return strlen($value) <= $length ? $value : substr($value, 0, $length - strip_tags($replace)).$replace;
101 101
     }
102 102
     
103 103
     /**
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
             ? '~(?:(https?)://([^\s<>]+)|(?<!\w@)\b(www\.[^\s<>]+?\.[^\s<>]+))(?<![\.,:;\?!\'"\|])~i'
116 116
             : '~(?:(https?)://([^\s<>]+)|(?<!\w@)\b([^\s<>@]+?\.[^\s<>]+)(?<![\.,:]))~i';
117 117
         
118
-        return preg_replace_callback($regexp, function ($match) use ($protocol, &$links, $attr) {
118
+        return preg_replace_callback($regexp, function($match) use ($protocol, &$links, $attr) {
119 119
             if ($match[1]) $protocol = $match[1];
120 120
             $link = $match[2] ?: $match[3];
121 121
             
122
-            return '<' . array_push($links, '<a' . $attr . ' href="' . $protocol . '://' . $link  . '">'
123
-                . rtrim($link, '/') . '</a>') . '>';
122
+            return '<'.array_push($links, '<a'.$attr.' href="'.$protocol.'://'.$link.'">'
123
+                . rtrim($link, '/').'</a>').'>';
124 124
         }, $text);
125 125
     }
126 126
     
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
     {
136 136
         $regexp = '~([^\s<>]+?@[^\s<>]+?\.[^\s<>]+)(?<![\.,:;\?!\'"\|])~';
137 137
         
138
-        return preg_replace_callback($regexp, function ($match) use (&$links, $attr) {
139
-            return '<' . array_push($links, '<a' . $attr . ' href="mailto:' . $match[1]  . '">' . $match[1] . '</a>')
138
+        return preg_replace_callback($regexp, function($match) use (&$links, $attr) {
139
+            return '<'.array_push($links, '<a'.$attr.' href="mailto:'.$match[1].'">'.$match[1].'</a>')
140 140
                 . '>';
141 141
         }, $text);
142 142
     }
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
     protected function linkifyOther($protocol, $text, array &$links, $attr, $mode)
155 155
     {
156 156
         if (strpos($protocol, ':') === false) {
157
-            $protocol .= in_array($protocol, ['ftp', 'tftp', 'ssh', 'scp'])  ? '://' : ':';
157
+            $protocol .= in_array($protocol, ['ftp', 'tftp', 'ssh', 'scp']) ? '://' : ':';
158 158
         }
159 159
         
160 160
         $regexp = $mode != 'all'
161
-            ? '~' . preg_quote($protocol, '~') . '([^\s<>]+)(?<![\.,:;\?!\'"\|])~i'
161
+            ? '~'.preg_quote($protocol, '~').'([^\s<>]+)(?<![\.,:;\?!\'"\|])~i'
162 162
             : '~([^\s<>]+)(?<![\.,:])~i';
163 163
         
164
-        return preg_replace_callback($regexp, function ($match) use ($protocol, &$links, $attr) {
165
-            return '<' . array_push($links, '<a' . $attr . ' href="' . $protocol . $match[1]  . '">' . $match[1]
166
-                . '</a>') . '>';
164
+        return preg_replace_callback($regexp, function($match) use ($protocol, &$links, $attr) {
165
+            return '<'.array_push($links, '<a'.$attr.' href="'.$protocol.$match[1].'">'.$match[1]
166
+                . '</a>').'>';
167 167
         }, $text);
168 168
     }
169 169
     
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
         // Link attributes
186 186
         $attr = '';
187 187
         foreach ($attributes as $key => $val) {
188
-            $attr .= ' ' . $key . '="' . htmlentities($val) . '"';
188
+            $attr .= ' '.$key.'="'.htmlentities($val).'"';
189 189
         }
190 190
         
191 191
         $links = [];
192 192
         
193 193
         // Extract existing links and tags
194
-        $text = preg_replace_callback('~(<a .*?>.*?</a>|<.*?>)~i', function ($match) use (&$links) {
195
-            return '<' . array_push($links, $match[1]) . '>';
194
+        $text = preg_replace_callback('~(<a .*?>.*?</a>|<.*?>)~i', function($match) use (&$links) {
195
+            return '<'.array_push($links, $match[1]).'>';
196 196
         }, $value);
197 197
         
198 198
         // Extract text links for each protocol
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         }
207 207
         
208 208
         // Insert all link
209
-        return preg_replace_callback('/<(\d+)>/', function ($match) use (&$links) {
209
+        return preg_replace_callback('/<(\d+)>/', function($match) use (&$links) {
210 210
             return $links[$match[1] - 1];
211 211
         }, $text);
212 212
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,9 @@
 block discarded – undo
116 116
             : '~(?:(https?)://([^\s<>]+)|(?<!\w@)\b([^\s<>@]+?\.[^\s<>]+)(?<![\.,:]))~i';
117 117
         
118 118
         return preg_replace_callback($regexp, function ($match) use ($protocol, &$links, $attr) {
119
-            if ($match[1]) $protocol = $match[1];
119
+            if ($match[1]) {
120
+                $protocol = $match[1];
121
+            }
120 122
             $link = $match[2] ?: $match[3];
121 123
             
122 124
             return '<' . array_push($links, '<a' . $attr . ' href="' . $protocol . '://' . $link  . '">'
Please login to merge, or discard this patch.
src/ArrayExtension.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function sum($array)
45 45
     {
46
-       if (!isset($array)) return null;
47
-       return array_sum((array)$array);
46
+        if (!isset($array)) return null;
47
+        return array_sum((array)$array);
48 48
     }
49 49
     
50 50
     /**
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function product($array)
57 57
     {
58
-       if (!isset($array)) return null;
59
-       return array_product((array)$array);
58
+        if (!isset($array)) return null;
59
+        return array_product((array)$array);
60 60
     }
61 61
     
62 62
     /**
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function values($array)
69 69
     {
70
-       if (!isset($array)) return null;
71
-       return array_values((array)$array);
70
+        if (!isset($array)) return null;
71
+        return array_values((array)$array);
72 72
     }
73 73
     
74 74
     
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@
 block discarded – undo
98 98
             if (!isset($value) || $value === false) continue;
99 99
             
100 100
             if ($value === true) $value = $key;
101
-            $str .= ' ' . $key . '="' . addcslashes($value, '"') . '"';
101
+            $str .= ' '.$key.'="'.addcslashes($value, '"').'"';
102 102
         }
103 103
         return trim($str);
104 104
     }
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,7 +43,9 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function sum($array)
45 45
     {
46
-       if (!isset($array)) return null;
46
+       if (!isset($array)) {
47
+           return null;
48
+       }
47 49
        return array_sum((array)$array);
48 50
     }
49 51
     
@@ -55,7 +57,9 @@  discard block
 block discarded – undo
55 57
      */
56 58
     public function product($array)
57 59
     {
58
-       if (!isset($array)) return null;
60
+       if (!isset($array)) {
61
+           return null;
62
+       }
59 63
        return array_product((array)$array);
60 64
     }
61 65
     
@@ -67,7 +71,9 @@  discard block
 block discarded – undo
67 71
      */
68 72
     public function values($array)
69 73
     {
70
-       if (!isset($array)) return null;
74
+       if (!isset($array)) {
75
+           return null;
76
+       }
71 77
        return array_values((array)$array);
72 78
     }
73 79
     
@@ -91,13 +97,19 @@  discard block
 block discarded – undo
91 97
      */
92 98
     public function HTMLAttributes($array)
93 99
     {
94
-        if (!isset($array)) return null;
100
+        if (!isset($array)) {
101
+            return null;
102
+        }
95 103
        
96 104
         $str = "";
97 105
         foreach ($array as $key=>$value) {
98
-            if (!isset($value) || $value === false) continue;
106
+            if (!isset($value) || $value === false) {
107
+                continue;
108
+            }
99 109
             
100
-            if ($value === true) $value = $key;
110
+            if ($value === true) {
111
+                $value = $key;
112
+            }
101 113
             $str .= ' ' . $key . '="' . addcslashes($value, '"') . '"';
102 114
         }
103 115
         return trim($str);
Please login to merge, or discard this patch.