Total Complexity | 3 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
20 | class TranslatorBladeProvider extends ServiceProvider |
||
21 | { |
||
22 | /** |
||
23 | * Bootstrap any application services. |
||
24 | */ |
||
25 | public function boot() { |
||
26 | Blade::directive('translate', function($expression) { |
||
27 | |||
28 | $expression = $this->stripParentheses($expression); |
||
29 | |||
30 | // Call the TranslatorFacade to translate the string |
||
31 | return "<?php echo Hokan22\\LaravelTranslator\\TranslatorFacade::translate({$expression}); ?>"; |
||
32 | } |
||
33 | ); |
||
34 | |||
35 | Blade::directive('t', function($expression) { |
||
36 | |||
37 | $expression = $this->stripParentheses($expression); |
||
38 | |||
39 | // Call the TranslatorFacade to translate the string |
||
40 | return "<?php echo Hokan22\\LaravelTranslator\\TranslatorFacade::translate({$expression}); ?>"; |
||
41 | } |
||
42 | ); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Strip the parentheses from the given expression. |
||
47 | * |
||
48 | * @param string $expression |
||
49 | * @return string |
||
50 | */ |
||
51 | public function stripParentheses($expression) { |
||
57 | } |
||
58 | } |
||
59 |