|
2 | 2 |
|
3 | 3 | namespace Webfactor\Laravel\Generators\Services; |
4 | 4 |
|
5 | | -use Illuminate\Filesystem\Filesystem; |
6 | | -use Webfactor\Laravel\Generators\Commands\MakeEntity; |
7 | 5 | use Webfactor\Laravel\Generators\Contracts\ServiceAbstract; |
8 | 6 | use Webfactor\Laravel\Generators\Contracts\ServiceInterface; |
| 7 | +use Webfactor\Laravel\Generators\Helper\ShortSyntaxArray; |
9 | 8 |
|
10 | 9 | class LanguageService extends ServiceAbstract implements ServiceInterface |
11 | 10 | { |
@@ -59,23 +58,12 @@ private function getFilePath() |
59 | 58 |
|
60 | 59 | private function getTranslationFileContent() |
61 | 60 | { |
| 61 | + $content = ShortSyntaxArray::parse($this->translation); |
| 62 | + |
62 | 63 | return <<<FILE |
63 | 64 | <?php |
64 | 65 | |
65 | | -return {$this->exportToShortSyntaxArrayString($this->translation)}; |
| 66 | +return {$content}; |
66 | 67 | FILE; |
67 | 68 | } |
68 | | - |
69 | | - private function exportToShortSyntaxArrayString(array $expression, $indent = 4) |
70 | | - { |
71 | | - $object = json_decode(str_replace(['(', ')'], ['(', ')'], json_encode($expression)), true); |
72 | | - $export = str_replace(['array (', ')', '(', ')'], ['[', ']', '(', ')'], var_export($object, true)); |
73 | | - $export = preg_replace("/ => \n[^\S\n]*\[/m", ' => [', $export); |
74 | | - $export = preg_replace("/ => \[\n[^\S\n]*\]/m", ' => []', $export); |
75 | | - $spaces = str_repeat(' ', $indent); |
76 | | - $export = preg_replace("/([ ]{2})(?![^ ])/m", $spaces, $export); |
77 | | - $export = preg_replace("/^([ ]{2})/m", $spaces, $export); |
78 | | - |
79 | | - return $export; |
80 | | - } |
81 | 69 | } |
0 commit comments