Test Failed
Pull Request — master (#53)
by
unknown
05:27
created
classes/TimeDiffTranslator.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
 {
8 8
     public function trans($id, array $parameters = [], $domain = 'messages', $locale = null)
9 9
     {
10
-        return $this->get('vojtasvoboda.twigextensions::lang.' . $id, $parameters, $locale);
10
+        return $this->get('vojtasvoboda.twigextensions::lang.'.$id, $parameters, $locale);
11 11
     }
12 12
 
13 13
     public function transChoice($id, $number, array $parameters = [], $domain = 'messages', $locale = null)
14 14
     {
15
-        return $this->choice('vojtasvoboda.twigextensions::lang.' . $id, $number, $parameters, $locale);
15
+        return $this->choice('vojtasvoboda.twigextensions::lang.'.$id, $number, $parameters, $locale);
16 16
     }
17 17
 }
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php namespace VojtaSvoboda\TwigExtensions\Classes;
2 2
 
3
-use App;
4 3
 use October\Rain\Translation\Translator;
5 4
 use Symfony\Component\Translation\TranslatorInterface;
6 5
 
Please login to merge, or discard this patch.
Plugin.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,5 @@
 block discarded – undo
1 1
 <?php namespace VojtaSvoboda\TwigExtensions;
2 2
 
3
-use App;
4
-use Backend;
5 3
 use Carbon\Carbon;
6 4
 use Snilius\Twig\SortByFieldExtension;
7 5
 use System\Classes\PluginBase;
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function boot()
44 44
     {
45
-        $this->app->singleton('time_diff_translator', function ($app) {
45
+        $this->app->singleton('time_diff_translator', function($app) {
46 46
             $loader = $app->make('translation.loader');
47 47
             $locale = $app->config->get('app.locale');
48 48
             $translator = $app->make(TimeDiffTranslator::class, [$loader, $locale]);
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         $stringLoaderFunc = $stringLoader->getFunctions();
137 137
 
138 138
         return [
139
-            'template_from_string' => function ($template) use ($twig, $stringLoaderFunc) {
139
+            'template_from_string' => function($template) use ($twig, $stringLoaderFunc) {
140 140
                 $callable = $stringLoaderFunc[0]->getCallable();
141 141
                 return $callable($twig, $template);
142 142
             }
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
         $textFilters = $textExtension->getFilters();
157 157
 
158 158
         return [
159
-            'truncate' => function ($value, $length = 30, $preserve = false, $separator = '...') use ($twig, $textFilters) {
159
+            'truncate' => function($value, $length = 30, $preserve = false, $separator = '...') use ($twig, $textFilters) {
160 160
                 $callable = $textFilters[0]->getCallable();
161 161
                 return $callable($twig, $value, $length, $preserve, $separator);
162 162
             },
163
-            'wordwrap' => function ($value, $length = 80, $separator = "\n", $preserve = false) use ($twig, $textFilters) {
163
+            'wordwrap' => function($value, $length = 80, $separator = "\n", $preserve = false) use ($twig, $textFilters) {
164 164
                 $callable = $textFilters[1]->getCallable();
165 165
                 return $callable($twig, $value, $length, $separator, $preserve);
166 166
             }
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
         $intlFilters = $intlExtension->getFilters();
181 181
 
182 182
         return [
183
-            'localizeddate' => function ($date, $dateFormat = 'medium', $timeFormat = 'medium', $locale = null, $timezone = null, $format = null) use ($twig, $intlFilters) {
183
+            'localizeddate' => function($date, $dateFormat = 'medium', $timeFormat = 'medium', $locale = null, $timezone = null, $format = null) use ($twig, $intlFilters) {
184 184
                 $callable = $intlFilters[0]->getCallable();
185 185
                 return $callable($twig, $date, $dateFormat, $timeFormat, $locale, $timezone, $format);
186 186
             },
187
-            'localizednumber' => function ($number, $style = 'decimal', $type = 'default', $locale = null) use ($twig, $intlFilters) {
187
+            'localizednumber' => function($number, $style = 'decimal', $type = 'default', $locale = null) use ($twig, $intlFilters) {
188 188
                 $callable = $intlFilters[1]->getCallable();
189 189
                 return $callable($number, $style, $type, $locale);
190 190
             },
191
-            'localizedcurrency' => function ($number, $currency = null, $locale = null) use ($twig, $intlFilters) {
191
+            'localizedcurrency' => function($number, $currency = null, $locale = null) use ($twig, $intlFilters) {
192 192
                 $callable = $intlFilters[2]->getCallable();
193 193
                 return $callable($number, $currency, $locale);
194 194
             }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         $arrayFilters = $arrayExtension->getFilters();
207 207
 
208 208
         return [
209
-            'shuffle' => function ($array) use ($arrayFilters) {
209
+            'shuffle' => function($array) use ($arrayFilters) {
210 210
                 $callable = $arrayFilters[0]->getCallable();
211 211
                 return $callable($array);
212 212
             }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         $timeFilters = $timeExtension->getFilters();
228 228
 
229 229
         return [
230
-            'time_diff' => function ($date, $now = null) use ($twig, $timeFilters) {
230
+            'time_diff' => function($date, $now = null) use ($twig, $timeFilters) {
231 231
                 $callable = $timeFilters[0]->getCallable();
232 232
                 return $callable($twig, $date, $now);
233 233
             }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         $filters = $extension->getFilters();
246 246
 
247 247
         return [
248
-            'sortbyfield' => function ($array, $sort_by = null, $direction = 'asc') use ($filters) {
248
+            'sortbyfield' => function($array, $sort_by = null, $direction = 'asc') use ($filters) {
249 249
                 $callable = $filters[0]->getCallable();
250 250
                 return $callable($array, $sort_by, $direction);
251 251
             }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
     private function getMailFilters()
261 261
     {
262 262
         return [
263
-            'mailto' => function ($string, $link = true, $protected = true, $text = null, $class = "") {
263
+            'mailto' => function($string, $link = true, $protected = true, $text = null, $class = "") {
264 264
                 return $this->hideEmail($string, $link, $protected, $text, $class);
265 265
             }
266 266
         ];
@@ -274,53 +274,53 @@  discard block
 block discarded – undo
274 274
     private function getPhpFunctions()
275 275
     {
276 276
         return [
277
-            'strftime' => function ($time, $format = '%d.%m.%Y %H:%M:%S') {
277
+            'strftime' => function($time, $format = '%d.%m.%Y %H:%M:%S') {
278 278
                 $timeObj = new Carbon($time);
279 279
                 return strftime($format, $timeObj->getTimestamp());
280 280
             },
281
-            'uppercase' => function ($string) {
281
+            'uppercase' => function($string) {
282 282
                 return mb_convert_case($string, MB_CASE_UPPER, "UTF-8");
283 283
             },
284
-            'lowercase' => function ($string) {
284
+            'lowercase' => function($string) {
285 285
                 return mb_convert_case($string, MB_CASE_LOWER, "UTF-8");
286 286
             },
287
-            'ucfirst' => function ($string) {
287
+            'ucfirst' => function($string) {
288 288
                 return mb_convert_case($string, MB_CASE_TITLE, "UTF-8");
289 289
             },
290
-            'lcfirst' => function ($string) {
290
+            'lcfirst' => function($string) {
291 291
                 return lcfirst($string);
292 292
             },
293
-            'ltrim' => function ($string, $charlist = " \t\n\r\0\x0B") {
293
+            'ltrim' => function($string, $charlist = " \t\n\r\0\x0B") {
294 294
                 return ltrim($string, $charlist);
295 295
             },
296
-            'rtrim' => function ($string, $charlist = " \t\n\r\0\x0B") {
296
+            'rtrim' => function($string, $charlist = " \t\n\r\0\x0B") {
297 297
                 return rtrim($string, $charlist);
298 298
             },
299
-            'str_repeat' => function ($string, $multiplier = 1) {
299
+            'str_repeat' => function($string, $multiplier = 1) {
300 300
                 return str_repeat($string, $multiplier);
301 301
             },
302
-            'plural' => function ($string, $count = 2) {
302
+            'plural' => function($string, $count = 2) {
303 303
                 return str_plural($string, $count);
304 304
             },
305
-            'strpad' => function ($string, $pad_length, $pad_string = ' ') {
305
+            'strpad' => function($string, $pad_length, $pad_string = ' ') {
306 306
                 return str_pad($string, $pad_length, $pad_string, $pad_type = STR_PAD_BOTH);
307 307
             },
308
-            'leftpad' => function ($string, $pad_length, $pad_string = ' ') {
308
+            'leftpad' => function($string, $pad_length, $pad_string = ' ') {
309 309
                 return str_pad($string, $pad_length, $pad_string, $pad_type = STR_PAD_LEFT);
310 310
             },
311
-            'rightpad' => function ($string, $pad_length, $pad_string = ' ') {
311
+            'rightpad' => function($string, $pad_length, $pad_string = ' ') {
312 312
                 return str_pad($string, $pad_length, $pad_string, $pad_type = STR_PAD_RIGHT);
313 313
             },
314
-            'rtl' => function ($string) {
314
+            'rtl' => function($string) {
315 315
                 return strrev($string);
316 316
             },
317
-            'str_replace' => function ($string, $search, $replace) {
317
+            'str_replace' => function($string, $search, $replace) {
318 318
                 return str_replace($search, $replace, $string);
319 319
             },
320
-            'strip_tags' => function ($string, $allow = '') {
320
+            'strip_tags' => function($string, $allow = '') {
321 321
                 return strip_tags($string, $allow);
322 322
             },
323
-            'var_dump' => function ($expression) {
323
+            'var_dump' => function($expression) {
324 324
                 ob_start();
325 325
                 var_dump($expression);
326 326
                 $result = ob_get_clean();
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
     private function getConfigFunction()
339 339
     {
340 340
         return [
341
-            'config' => function ($key = null, $default = null) {
341
+            'config' => function($key = null, $default = null) {
342 342
                 return config($key, $default);
343 343
             },
344 344
         ];
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
     private function getEnvFunction()
353 353
     {
354 354
         return [
355
-            'env' => function ($key, $default = null) {
355
+            'env' => function($key, $default = null) {
356 356
                 return env($key, $default);
357 357
             },
358 358
         ];
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     private function getSessionFunction()
367 367
     {
368 368
         return [
369
-            'session' => function ($key = null) {
369
+            'session' => function($key = null) {
370 370
                 return session($key);
371 371
             },
372 372
         ];
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
     private function getRedirectFunction()
382 382
     {
383 383
         return [
384
-            'redirect' => function ($url) {
384
+            'redirect' => function($url) {
385 385
 
386
-                if(empty($url)) {
386
+                if (empty($url)) {
387 387
                     return;
388 388
                 }
389 389
 
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     private function getTransFunction()
401 401
     {
402 402
         return [
403
-            'trans' => function ($key = null, $parameters = []) {
403
+            'trans' => function($key = null, $parameters = []) {
404 404
                 return trans($key, $parameters);
405 405
             },
406 406
         ];
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
     private function getVarDumpFunction()
415 415
     {
416 416
         return [
417
-            'var_dump' => function ($expression) {
417
+            'var_dump' => function($expression) {
418 418
                 ob_start();
419 419
                 var_dump($expression);
420 420
                 $result = ob_get_clean();
@@ -448,32 +448,32 @@  discard block
 block discarded – undo
448 448
 
449 449
         // if we want just unprotected link
450 450
         if (!$protected) {
451
-            return $link ? '<a href="mailto:' . $email . '">' . $linkText . '</a>' : $linkText;
451
+            return $link ? '<a href="mailto:'.$email.'">'.$linkText.'</a>' : $linkText;
452 452
         }
453 453
 
454 454
         // turn on protection
455 455
         $character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
456 456
         $key = str_shuffle($character_set);
457 457
         $cipher_text = '';
458
-        $id = 'e' . rand(1, 999999999);
458
+        $id = 'e'.rand(1, 999999999);
459 459
         for ($i = 0; $i < strlen($email); $i += 1) {
460 460
             $cipher_text .= $key[strpos($character_set, $email[$i])];
461 461
         }
462
-        $script = 'var a="' . $key . '";var b=a.split("").sort().join("");var c="' . $cipher_text . '";var d=""; var cl="'.$class.'";';
462
+        $script = 'var a="'.$key.'";var b=a.split("").sort().join("");var c="'.$cipher_text.'";var d=""; var cl="'.$class.'";';
463 463
         $script .= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));';
464 464
         $script .= 'var y = d;';
465 465
         if ($text !== null) {
466 466
             $script .= 'var y = "'.$text.'";';
467 467
         }
468 468
         if ($link) {
469
-            $script .= 'document.getElementById("' . $id . '").innerHTML="<a class=\""+cl+"\" href=\\"mailto:"+d+"\\">"+y+"</a>"';
469
+            $script .= 'document.getElementById("'.$id.'").innerHTML="<a class=\""+cl+"\" href=\\"mailto:"+d+"\\">"+y+"</a>"';
470 470
         } else {
471
-            $script .= 'document.getElementById("' . $id . '").innerHTML=y';
471
+            $script .= 'document.getElementById("'.$id.'").innerHTML=y';
472 472
         }
473
-        $script = "eval(\"" . str_replace(array("\\", '"'), array("\\\\", '\"'), $script) . "\")";
474
-        $script = '<script type="text/javascript">/*<![CDATA[*/' . $script . '/*]]>*/</script>';
473
+        $script = "eval(\"".str_replace(array("\\", '"'), array("\\\\", '\"'), $script)."\")";
474
+        $script = '<script type="text/javascript">/*<![CDATA[*/'.$script.'/*]]>*/</script>';
475 475
 
476
-        return '<span id="' . $id . '">[javascript protected email address]</span>' . $script;
476
+        return '<span id="'.$id.'">[javascript protected email address]</span>'.$script;
477 477
     }
478 478
 
479 479
     /**
@@ -488,15 +488,15 @@  discard block
 block discarded – undo
488 488
     private function getFileRevision()
489 489
     {
490 490
         return [
491
-            'revision' => function ($filename, $format = null) {
491
+            'revision' => function($filename, $format = null) {
492 492
                 // Remove http/web address from the file name if there is one to load it locally
493 493
                 $prefix = url('/');
494
-                $filename_ = trim(preg_replace('/^' . preg_quote($prefix, '/') . '/', '', $filename), '/');
494
+                $filename_ = trim(preg_replace('/^'.preg_quote($prefix, '/').'/', '', $filename), '/');
495 495
                 if (file_exists($filename_)) {
496 496
                     $timestamp = filemtime($filename_);
497 497
                     $prepend = ($format) ? date($format, $timestamp) : $timestamp;
498 498
 
499
-                    return $filename . "?" . $prepend;
499
+                    return $filename."?".$prepend;
500 500
                 }
501 501
 
502 502
                 return $filename;
Please login to merge, or discard this patch.
tests/PluginTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Twig_Environment;
8 8
 use VojtaSvoboda\TwigExtensions\Classes\TimeDiffTranslator;
9 9
 
10
-require_once __DIR__ . '/../vendor/autoload.php';
10
+require_once __DIR__.'/../vendor/autoload.php';
11 11
 
12 12
 class PluginTest extends PluginTestCase
13 13
 {
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
         $this->app->setLocale('en');
19 19
 
20
-        $this->app->singleton('time_diff_translator', function ($app) {
20
+        $this->app->singleton('time_diff_translator', function($app) {
21 21
             $loader = $app->make('translation.loader');
22 22
             $locale = $app->config->get('app.locale');
23 23
             $translator = $app->make(TimeDiffTranslator::class, [$loader, $locale]);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         $twig = $this->getTwig();
115 115
 
116 116
         $now = Carbon::now()->subMinute();
117
-        $template = "{{ '" . $now->format('Y-m-d H:i:s') . "' | time_diff }}";
117
+        $template = "{{ '".$now->format('Y-m-d H:i:s')."' | time_diff }}";
118 118
 
119 119
         // this test fails at TravisCI and I don't know why
120 120
         $twigTemplate = $twig->createTemplate($template);
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
         $key = 'app.custom.key';
352 352
         $value = 'test value';
353 353
         Config::set($key, $value);
354
-        $template = "{{ config('" . $key . "') }}";
354
+        $template = "{{ config('".$key."') }}";
355 355
 
356 356
         $twigTemplate = $twig->createTemplate($template);
357 357
         $this->assertEquals($twigTemplate->render([]), $value);
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
         $key = 'env.custom.key';
365 365
         $value = 'test value';
366 366
         putenv($key.'='.$value);
367
-        $template = "{{ env('" . $key . "') }}";
367
+        $template = "{{ env('".$key."') }}";
368 368
 
369 369
         $twigTemplate = $twig->createTemplate($template);
370 370
         $this->assertEquals($twigTemplate->render([]), $value);
Please login to merge, or discard this patch.