@@ -7,11 +7,11 @@ |
||
| 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 | } |
@@ -1,6 +1,5 @@ |
||
| 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 | |
@@ -1,7 +1,5 @@ |
||
| 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; |
@@ -42,7 +42,7 @@ discard block |
||
| 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]); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $stringLoaderFunc = $stringLoader->getFunctions(); |
| 134 | 134 | |
| 135 | 135 | return [ |
| 136 | - 'template_from_string' => function ($template) use ($twig, $stringLoaderFunc) { |
|
| 136 | + 'template_from_string' => function($template) use ($twig, $stringLoaderFunc) { |
|
| 137 | 137 | $callable = $stringLoaderFunc[0]->getCallable(); |
| 138 | 138 | return $callable($twig, $template); |
| 139 | 139 | } |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | $textFilters = $textExtension->getFilters(); |
| 154 | 154 | |
| 155 | 155 | return [ |
| 156 | - 'truncate' => function ($value, $length = 30, $preserve = false, $separator = '...') use ($twig, $textFilters) { |
|
| 156 | + 'truncate' => function($value, $length = 30, $preserve = false, $separator = '...') use ($twig, $textFilters) { |
|
| 157 | 157 | $callable = $textFilters[0]->getCallable(); |
| 158 | 158 | return $callable($twig, $value, $length, $preserve, $separator); |
| 159 | 159 | }, |
| 160 | - 'wordwrap' => function ($value, $length = 80, $separator = "\n", $preserve = false) use ($twig, $textFilters) { |
|
| 160 | + 'wordwrap' => function($value, $length = 80, $separator = "\n", $preserve = false) use ($twig, $textFilters) { |
|
| 161 | 161 | $callable = $textFilters[1]->getCallable(); |
| 162 | 162 | return $callable($twig, $value, $length, $separator, $preserve); |
| 163 | 163 | } |
@@ -177,15 +177,15 @@ discard block |
||
| 177 | 177 | $intlFilters = $intlExtension->getFilters(); |
| 178 | 178 | |
| 179 | 179 | return [ |
| 180 | - 'localizeddate' => function ($date, $dateFormat = 'medium', $timeFormat = 'medium', $locale = null, $timezone = null, $format = null) use ($twig, $intlFilters) { |
|
| 180 | + 'localizeddate' => function($date, $dateFormat = 'medium', $timeFormat = 'medium', $locale = null, $timezone = null, $format = null) use ($twig, $intlFilters) { |
|
| 181 | 181 | $callable = $intlFilters[0]->getCallable(); |
| 182 | 182 | return $callable($twig, $date, $dateFormat, $timeFormat, $locale, $timezone, $format); |
| 183 | 183 | }, |
| 184 | - 'localizednumber' => function ($number, $style = 'decimal', $type = 'default', $locale = null) use ($twig, $intlFilters) { |
|
| 184 | + 'localizednumber' => function($number, $style = 'decimal', $type = 'default', $locale = null) use ($twig, $intlFilters) { |
|
| 185 | 185 | $callable = $intlFilters[1]->getCallable(); |
| 186 | 186 | return $callable($number, $style, $type, $locale); |
| 187 | 187 | }, |
| 188 | - 'localizedcurrency' => function ($number, $currency = null, $locale = null) use ($twig, $intlFilters) { |
|
| 188 | + 'localizedcurrency' => function($number, $currency = null, $locale = null) use ($twig, $intlFilters) { |
|
| 189 | 189 | $callable = $intlFilters[2]->getCallable(); |
| 190 | 190 | return $callable($number, $currency, $locale); |
| 191 | 191 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $arrayFilters = $arrayExtension->getFilters(); |
| 204 | 204 | |
| 205 | 205 | return [ |
| 206 | - 'shuffle' => function ($array) use ($arrayFilters) { |
|
| 206 | + 'shuffle' => function($array) use ($arrayFilters) { |
|
| 207 | 207 | $callable = $arrayFilters[0]->getCallable(); |
| 208 | 208 | return $callable($array); |
| 209 | 209 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $timeFilters = $timeExtension->getFilters(); |
| 225 | 225 | |
| 226 | 226 | return [ |
| 227 | - 'time_diff' => function ($date, $now = null) use ($twig, $timeFilters) { |
|
| 227 | + 'time_diff' => function($date, $now = null) use ($twig, $timeFilters) { |
|
| 228 | 228 | $callable = $timeFilters[0]->getCallable(); |
| 229 | 229 | return $callable($twig, $date, $now); |
| 230 | 230 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $filters = $extension->getFilters(); |
| 243 | 243 | |
| 244 | 244 | return [ |
| 245 | - 'sortbyfield' => function ($array, $sort_by = null, $direction = 'asc') use ($filters) { |
|
| 245 | + 'sortbyfield' => function($array, $sort_by = null, $direction = 'asc') use ($filters) { |
|
| 246 | 246 | $callable = $filters[0]->getCallable(); |
| 247 | 247 | return $callable($array, $sort_by, $direction); |
| 248 | 248 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | private function getMailFilters() |
| 258 | 258 | { |
| 259 | 259 | return [ |
| 260 | - 'mailto' => function ($string, $link = true, $protected = true, $text = null, $class = "") { |
|
| 260 | + 'mailto' => function($string, $link = true, $protected = true, $text = null, $class = "") { |
|
| 261 | 261 | return $this->hideEmail($string, $link, $protected, $text, $class); |
| 262 | 262 | } |
| 263 | 263 | ]; |
@@ -271,53 +271,53 @@ discard block |
||
| 271 | 271 | private function getPhpFunctions() |
| 272 | 272 | { |
| 273 | 273 | return [ |
| 274 | - 'strftime' => function ($time, $format = '%d.%m.%Y %H:%M:%S') { |
|
| 274 | + 'strftime' => function($time, $format = '%d.%m.%Y %H:%M:%S') { |
|
| 275 | 275 | $timeObj = new Carbon($time); |
| 276 | 276 | return strftime($format, $timeObj->getTimestamp()); |
| 277 | 277 | }, |
| 278 | - 'uppercase' => function ($string) { |
|
| 278 | + 'uppercase' => function($string) { |
|
| 279 | 279 | return mb_convert_case($string, MB_CASE_UPPER, "UTF-8"); |
| 280 | 280 | }, |
| 281 | - 'lowercase' => function ($string) { |
|
| 281 | + 'lowercase' => function($string) { |
|
| 282 | 282 | return mb_convert_case($string, MB_CASE_LOWER, "UTF-8"); |
| 283 | 283 | }, |
| 284 | - 'ucfirst' => function ($string) { |
|
| 284 | + 'ucfirst' => function($string) { |
|
| 285 | 285 | return ucfirst($string); |
| 286 | 286 | }, |
| 287 | - 'lcfirst' => function ($string) { |
|
| 287 | + 'lcfirst' => function($string) { |
|
| 288 | 288 | return lcfirst($string); |
| 289 | 289 | }, |
| 290 | - 'ltrim' => function ($string, $charlist = " \t\n\r\0\x0B") { |
|
| 290 | + 'ltrim' => function($string, $charlist = " \t\n\r\0\x0B") { |
|
| 291 | 291 | return ltrim($string, $charlist); |
| 292 | 292 | }, |
| 293 | - 'rtrim' => function ($string, $charlist = " \t\n\r\0\x0B") { |
|
| 293 | + 'rtrim' => function($string, $charlist = " \t\n\r\0\x0B") { |
|
| 294 | 294 | return rtrim($string, $charlist); |
| 295 | 295 | }, |
| 296 | - 'str_repeat' => function ($string, $multiplier = 1) { |
|
| 296 | + 'str_repeat' => function($string, $multiplier = 1) { |
|
| 297 | 297 | return str_repeat($string, $multiplier); |
| 298 | 298 | }, |
| 299 | - 'plural' => function ($string, $count = 2) { |
|
| 299 | + 'plural' => function($string, $count = 2) { |
|
| 300 | 300 | return str_plural($string, $count); |
| 301 | 301 | }, |
| 302 | - 'strpad' => function ($string, $pad_length, $pad_string = ' ') { |
|
| 302 | + 'strpad' => function($string, $pad_length, $pad_string = ' ') { |
|
| 303 | 303 | return str_pad($string, $pad_length, $pad_string, $pad_type = STR_PAD_BOTH); |
| 304 | 304 | }, |
| 305 | - 'leftpad' => function ($string, $pad_length, $pad_string = ' ') { |
|
| 305 | + 'leftpad' => function($string, $pad_length, $pad_string = ' ') { |
|
| 306 | 306 | return str_pad($string, $pad_length, $pad_string, $pad_type = STR_PAD_LEFT); |
| 307 | 307 | }, |
| 308 | - 'rightpad' => function ($string, $pad_length, $pad_string = ' ') { |
|
| 308 | + 'rightpad' => function($string, $pad_length, $pad_string = ' ') { |
|
| 309 | 309 | return str_pad($string, $pad_length, $pad_string, $pad_type = STR_PAD_RIGHT); |
| 310 | 310 | }, |
| 311 | - 'rtl' => function ($string) { |
|
| 311 | + 'rtl' => function($string) { |
|
| 312 | 312 | return strrev($string); |
| 313 | 313 | }, |
| 314 | - 'str_replace' => function ($string, $search, $replace) { |
|
| 314 | + 'str_replace' => function($string, $search, $replace) { |
|
| 315 | 315 | return str_replace($search, $replace, $string); |
| 316 | 316 | }, |
| 317 | - 'strip_tags' => function ($string, $allow = '') { |
|
| 317 | + 'strip_tags' => function($string, $allow = '') { |
|
| 318 | 318 | return strip_tags($string, $allow); |
| 319 | 319 | }, |
| 320 | - 'var_dump' => function ($expression) { |
|
| 320 | + 'var_dump' => function($expression) { |
|
| 321 | 321 | ob_start(); |
| 322 | 322 | var_dump($expression); |
| 323 | 323 | $result = ob_get_clean(); |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | private function getConfigFunction() |
| 336 | 336 | { |
| 337 | 337 | return [ |
| 338 | - 'config' => function ($key = null, $default = null) { |
|
| 338 | + 'config' => function($key = null, $default = null) { |
|
| 339 | 339 | return config($key, $default); |
| 340 | 340 | }, |
| 341 | 341 | ]; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | private function getEnvFunction() |
| 350 | 350 | { |
| 351 | 351 | return [ |
| 352 | - 'env' => function ($key, $default = null) { |
|
| 352 | + 'env' => function($key, $default = null) { |
|
| 353 | 353 | return env($key, $default); |
| 354 | 354 | }, |
| 355 | 355 | ]; |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | private function getSessionFunction() |
| 364 | 364 | { |
| 365 | 365 | return [ |
| 366 | - 'session' => function ($key = null) { |
|
| 366 | + 'session' => function($key = null) { |
|
| 367 | 367 | return session($key); |
| 368 | 368 | }, |
| 369 | 369 | ]; |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | private function getTransFunction() |
| 378 | 378 | { |
| 379 | 379 | return [ |
| 380 | - 'trans' => function ($key = null, $parameters = []) { |
|
| 380 | + 'trans' => function($key = null, $parameters = []) { |
|
| 381 | 381 | return trans($key, $parameters); |
| 382 | 382 | }, |
| 383 | 383 | ]; |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | private function getVarDumpFunction() |
| 392 | 392 | { |
| 393 | 393 | return [ |
| 394 | - 'var_dump' => function ($expression) { |
|
| 394 | + 'var_dump' => function($expression) { |
|
| 395 | 395 | ob_start(); |
| 396 | 396 | var_dump($expression); |
| 397 | 397 | $result = ob_get_clean(); |
@@ -423,32 +423,32 @@ discard block |
||
| 423 | 423 | |
| 424 | 424 | // if we want just unprotected link |
| 425 | 425 | if (!$protected) { |
| 426 | - return $link ? '<a href="mailto:' . $email . '">' . $linkText . '</a>' : $linkText; |
|
| 426 | + return $link ? '<a href="mailto:'.$email.'">'.$linkText.'</a>' : $linkText; |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | // turn on protection |
| 430 | 430 | $character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'; |
| 431 | 431 | $key = str_shuffle($character_set); |
| 432 | 432 | $cipher_text = ''; |
| 433 | - $id = 'e' . rand(1, 999999999); |
|
| 433 | + $id = 'e'.rand(1, 999999999); |
|
| 434 | 434 | for ($i = 0; $i < strlen($email); $i += 1) { |
| 435 | 435 | $cipher_text .= $key[strpos($character_set, $email[$i])]; |
| 436 | 436 | } |
| 437 | - $script = 'var a="' . $key . '";var b=a.split("").sort().join("");var c="' . $cipher_text . '";var d=""; var cl="'.$class.'";'; |
|
| 437 | + $script = 'var a="'.$key.'";var b=a.split("").sort().join("");var c="'.$cipher_text.'";var d=""; var cl="'.$class.'";'; |
|
| 438 | 438 | $script .= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));'; |
| 439 | 439 | $script .= 'var y = d;'; |
| 440 | 440 | if ($text !== null) { |
| 441 | 441 | $script .= 'var y = "'.$text.'";'; |
| 442 | 442 | } |
| 443 | 443 | if ($link) { |
| 444 | - $script .= 'document.getElementById("' . $id . '").innerHTML="<a class=\""+cl+"\" href=\\"mailto:"+d+"\\">"+y+"</a>"'; |
|
| 444 | + $script .= 'document.getElementById("'.$id.'").innerHTML="<a class=\""+cl+"\" href=\\"mailto:"+d+"\\">"+y+"</a>"'; |
|
| 445 | 445 | } else { |
| 446 | - $script .= 'document.getElementById("' . $id . '").innerHTML=y'; |
|
| 446 | + $script .= 'document.getElementById("'.$id.'").innerHTML=y'; |
|
| 447 | 447 | } |
| 448 | - $script = "eval(\"" . str_replace(array("\\", '"'), array("\\\\", '\"'), $script) . "\")"; |
|
| 449 | - $script = '<script type="text/javascript">/*<![CDATA[*/' . $script . '/*]]>*/</script>'; |
|
| 448 | + $script = "eval(\"".str_replace(array("\\", '"'), array("\\\\", '\"'), $script)."\")"; |
|
| 449 | + $script = '<script type="text/javascript">/*<![CDATA[*/'.$script.'/*]]>*/</script>'; |
|
| 450 | 450 | |
| 451 | - return '<span id="' . $id . '">[javascript protected email address]</span>' . $script; |
|
| 451 | + return '<span id="'.$id.'">[javascript protected email address]</span>'.$script; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -463,15 +463,15 @@ discard block |
||
| 463 | 463 | private function getFileRevision() |
| 464 | 464 | { |
| 465 | 465 | return [ |
| 466 | - 'revision' => function ($filename, $format = null) { |
|
| 466 | + 'revision' => function($filename, $format = null) { |
|
| 467 | 467 | // Remove http/web address from the file name if there is one to load it locally |
| 468 | 468 | $prefix = url('/'); |
| 469 | - $filename_ = trim(preg_replace('/^' . preg_quote($prefix, '/') . '/', '', $filename), '/'); |
|
| 469 | + $filename_ = trim(preg_replace('/^'.preg_quote($prefix, '/').'/', '', $filename), '/'); |
|
| 470 | 470 | if (file_exists($filename_)) { |
| 471 | 471 | $timestamp = filemtime($filename_); |
| 472 | 472 | $prepend = ($format) ? date($format, $timestamp) : $timestamp; |
| 473 | 473 | |
| 474 | - return $filename . "?" . $prepend; |
|
| 474 | + return $filename."?".$prepend; |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | return $filename; |
@@ -7,7 +7,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |