Passed
Branch master (b3bcb6)
by Alexander
02:29
created
src/Commands/SearchTranslationsCommand.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
             'js'        => '/\$filter\(\'translate\'\)\(\'(?\'identifier\'.*?)\'\)/'
77 77
         ];
78 78
 
79
-        foreach($folders as $folder) {
80
-            $aFiles = array_merge($aFiles, File::allFiles(base_path().'/'.$folder));
79
+        foreach ($folders as $folder) {
80
+            $aFiles = array_merge($aFiles, File::allFiles(base_path() . '/' . $folder));
81 81
         }
82 82
 
83 83
         TranslatorFacade::setLocale('de_DE');
@@ -85,20 +85,20 @@  discard block
 block discarded – undo
85 85
         $num_files = count($aFiles);
86 86
 
87 87
         $this->bar = $this->output->createProgressBar($num_files);
88
-        $this->bar->setMessage('Analyzing '.$num_files.' files');
88
+        $this->bar->setMessage('Analyzing ' . $num_files . ' files');
89 89
         $this->bar->setFormat('very_verbose');
90 90
 
91 91
         foreach ($aFiles as $file) {
92 92
 
93 93
             $extension = $file->getExtension();
94 94
 
95
-            if(in_array($extension, $valid_extensions)) {
95
+            if (in_array($extension, $valid_extensions)) {
96 96
                 $content = file_get_contents($file);
97 97
 
98 98
                 foreach ($regexes as $key => $regex) {
99 99
                     preg_match_all($regex, $content, $result, PREG_SET_ORDER);
100 100
 
101
-                    if(!empty($result[0])) {
101
+                    if (!empty($result[0])) {
102 102
                         $this->addMissing($result, $key);
103 103
                     }
104 104
                 }
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
             ['Num', 'Translations...'],
115 115
             [
116 116
                 [$this->found_identifier, "Found"],
117
-                [$this->new_identifier,   "New"],
118
-                [$this->dupl_identifier,  "Duplicates"],
117
+                [$this->new_identifier, "New"],
118
+                [$this->dupl_identifier, "Duplicates"],
119 119
                 [$this->found_parameters, "With Parameters"],
120
-                [$this->found_invalid,    "Invalid"],
120
+                [$this->found_invalid, "Invalid"],
121 121
             ]
122 122
         );
123 123
 
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
                         $parameter_string = substr($parameter_string, 1, -1);
149 149
                     }
150 150
 
151
-                    $parameter_array = explode(",",$parameter_string);
151
+                    $parameter_array = explode(",", $parameter_string);
152 152
                     $parameters = array();
153 153
 
154
-                    foreach($parameter_array as $parameter) {
155
-                        $parameter = explode("=>",$parameter);
154
+                    foreach ($parameter_array as $parameter) {
155
+                        $parameter = explode("=>", $parameter);
156 156
 
157
-                        $key = str_replace([" ", "'"],"", $parameter[0]);
158
-                        $value = str_replace([" ", "'"],"", $parameter[1]);
157
+                        $key = str_replace([" ", "'"], "", $parameter[0]);
158
+                        $value = str_replace([" ", "'"], "", $parameter[1]);
159 159
 
160 160
                         $parameters[$key] = $value;
161 161
                     }
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
                     $this->found_parameters++;
164 164
                 }
165 165
 
166
-                if(!isset($aTranslations[$identifier])) {
166
+                if (!isset($aTranslations[$identifier])) {
167 167
                     $aTranslations[$identifier] = TranslatorFacade::hasIdentifier($identifier);
168 168
 
169 169
                     if (!$aTranslations[$identifier]) {
170 170
                         TranslatorFacade::addMissingIdentifier($identifier, $parameters, $group);
171 171
                         $this->bar->clear();
172
-                        $this->info('Adding: "'.$identifier.'" to database');
172
+                        $this->info('Adding: "' . $identifier . '" to database');
173 173
                         $this->bar->display();
174 174
                         $this->new_identifier++;
175 175
                     }
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
                     $this->dupl_identifier++;
178 178
                 }
179 179
 
180
-            } catch(\Exception $e){
180
+            } catch (\Exception $e) {
181 181
                 $this->bar->clear();
182
-                $this->info($identifier.' '.strlen($identifier));
182
+                $this->info($identifier . ' ' . strlen($identifier));
183 183
                 $this->info($e->getMessage());
184 184
                 $this->line('');
185 185
                 $this->bar->display();
Please login to merge, or discard this patch.
Braces   +4 added lines, -7 removed lines patch added patch discarded remove patch
@@ -45,8 +45,7 @@  discard block
 block discarded – undo
45 45
     /**
46 46
      * Create a new command instance.
47 47
      */
48
-    public function __construct()
49
-    {
48
+    public function __construct() {
50 49
         parent::__construct();
51 50
     }
52 51
 
@@ -56,8 +55,7 @@  discard block
 block discarded – undo
56 55
      * @return mixed
57 56
      * @throws \Exception
58 57
      */
59
-    public function handle()
60
-    {
58
+    public function handle() {
61 59
         $start = microtime(true);
62 60
 
63 61
         $this->line('');
@@ -132,8 +130,7 @@  discard block
 block discarded – undo
132 130
      * @param array $result Array with
133 131
      * @param string $group
134 132
      */
135
-    protected function addMissing($result, $group)
136
-    {
133
+    protected function addMissing($result, $group) {
137 134
         foreach ($result as $item) {
138 135
             try {
139 136
                 $identifier = trim($item['identifier']);
@@ -177,7 +174,7 @@  discard block
 block discarded – undo
177 174
                     $this->dupl_identifier++;
178 175
                 }
179 176
 
180
-            } catch(\Exception $e){
177
+            } catch(\Exception $e) {
181 178
                 $this->bar->clear();
182 179
                 $this->info($identifier.' '.strlen($identifier));
183 180
                 $this->info($e->getMessage());
Please login to merge, or discard this patch.
src/Commands/CacheTranslationCommand.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
             return;
60 60
         }
61 61
 
62
-        $file_path = TranslatorFacade::getConfigValue('cache_path').$locale.'/';
62
+        $file_path = TranslatorFacade::getConfigValue('cache_path') . $locale . '/';
63 63
 
64 64
         $groups = $this->getGroups();
65 65
         $translations = $this->loadFromDB($locale);
66 66
 
67 67
         if (!file_exists($file_path)) {
68
-            $this->alert("The defined cache folder (".$file_path.") does not exists.");
68
+            $this->alert("The defined cache folder (" . $file_path . ") does not exists.");
69 69
             if (!$this->confirm('Do you want to create it now?')) {
70 70
                 return;
71 71
             }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             }
89 89
 
90 90
             if (!empty($array)) {
91
-                $file_name = $file_path.$group.'.json';
91
+                $file_name = $file_path . $group . '.json';
92 92
                 file_put_contents($file_name, json_encode($array));
93 93
             }
94 94
         }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     {
115 115
         $trans_identifier = new TranslationIdentifier();
116 116
 
117
-        $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function ($item) use ($locale)
117
+        $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function($item) use ($locale)
118 118
         {
119 119
             return $item->where('locale', $locale);
120 120
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,8 +39,7 @@  discard block
 block discarded – undo
39 39
     /**
40 40
      * Create a new command instance.
41 41
      */
42
-    public function __construct()
43
-    {
42
+    public function __construct() {
44 43
         parent::__construct();
45 44
     }
46 45
 
@@ -49,8 +48,7 @@  discard block
 block discarded – undo
49 48
      *
50 49
      * @throws \Exception
51 50
      */
52
-    public function handle()
53
-    {
51
+    public function handle() {
54 52
         $locale = $this->argument('locale');
55 53
 
56 54
         if (!is_string($locale))
@@ -99,8 +97,7 @@  discard block
 block discarded – undo
99 97
      *
100 98
      * @return array
101 99
      */
102
-    protected function getGroups()
103
-    {
100
+    protected function getGroups() {
104 101
         return DB::table('translation_identifiers')->select('group')->groupBy(['group'])->get()->pluck('group');
105 102
     }
106 103
 
@@ -110,12 +107,10 @@  discard block
 block discarded – undo
110 107
      * @param string $locale The locale from which the translations to load
111 108
      * @return TranslationIdentifier|\Illuminate\Database\Eloquent\Collection|static[]
112 109
      */
113
-    protected function loadFromDB($locale)
114
-    {
110
+    protected function loadFromDB($locale) {
115 111
         $trans_identifier = new TranslationIdentifier();
116 112
 
117
-        $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function ($item) use ($locale)
118
-        {
113
+        $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function ($item) use ($locale) {
119 114
             return $item->where('locale', $locale);
120 115
         }
121 116
         )->orWhereHas('translations', null, '<=', 0)
Please login to merge, or discard this patch.
src/Provider/TranslatorProvider.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function register()
26 26
     {
27
-        $this->mergeConfigFrom(__DIR__.'/../config/translator.php', 'translator');
27
+        $this->mergeConfigFrom(__DIR__ . '/../config/translator.php', 'translator');
28 28
 
29
-        $this->app->singleton('Translator', function () {
29
+        $this->app->singleton('Translator', function() {
30 30
                 return new Translator();
31 31
             }
32 32
         );
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
             'config'
44 44
         );
45 45
 
46
-        $this->loadMigrationsFrom(__DIR__.'/../migrations/');
47
-        $this->loadRoutesFrom(__DIR__.'/../resources/routes.php');
48
-        $this->loadViewsFrom(__DIR__.'/../resources/views', 'translator');
46
+        $this->loadMigrationsFrom(__DIR__ . '/../migrations/');
47
+        $this->loadRoutesFrom(__DIR__ . '/../resources/routes.php');
48
+        $this->loadViewsFrom(__DIR__ . '/../resources/views', 'translator');
49 49
 
50 50
         if ($this->app->runningInConsole()) {
51 51
             $this->commands([
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
     /**
23 23
      * Register any application services.
24 24
      */
25
-    public function register()
26
-    {
25
+    public function register() {
27 26
         $this->mergeConfigFrom(__DIR__.'/../config/translator.php', 'translator');
28 27
 
29 28
         $this->app->singleton('Translator', function () {
@@ -35,8 +34,7 @@  discard block
 block discarded – undo
35 34
     /**
36 35
      * Bootstrap any application services.
37 36
      */
38
-    public function boot()
39
-    {
37
+    public function boot() {
40 38
         $this->publishes([
41 39
                 __DIR__ . '/../config/translator.php' => config_path('translator.php'),
42 40
             ],
Please login to merge, or discard this patch.
src/Controllers/TranslatorAdminController.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $query = TranslationIdentifier::with('translations');
36 36
 
37 37
         if ($locale != '') {
38
-            $query = $query->whereDoesntHave('translations', function ($query) use ($locale)
38
+            $query = $query->whereDoesntHave('translations', function($query) use ($locale)
39 39
                 {
40 40
                     $query->where('translations.locale', 'like', $locale);
41 41
                 }
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
         }
44 44
 
45 45
         if ($search != '') {
46
-            $query = $query->where(function ($query) use ($search) {
47
-                $query ->where('identifier',     'LIKE', '%'.$search.'%')
48
-                    ->orWhere('parameters', 'LIKE', '%'.$search.'%')
49
-                    ->orWhere('group',      'LIKE', '%'.$search.'%')
50
-                    ->orWhere('page_name',  'LIKE', '%'.$search.'%')
51
-                    ->orWhere('description','LIKE', '%'.$search.'%');
46
+            $query = $query->where(function($query) use ($search) {
47
+                $query ->where('identifier', 'LIKE', '%' . $search . '%')
48
+                    ->orWhere('parameters', 'LIKE', '%' . $search . '%')
49
+                    ->orWhere('group', 'LIKE', '%' . $search . '%')
50
+                    ->orWhere('page_name', 'LIKE', '%' . $search . '%')
51
+                    ->orWhere('description', 'LIKE', '%' . $search . '%');
52 52
             });
53 53
         }
54 54
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      * @param $state string 'enabled|disabled'
169 169
      * @return \Illuminate\Http\RedirectResponse
170 170
      */
171
-    public function changeLiveMode ($state)
171
+    public function changeLiveMode($state)
172 172
     {
173 173
         if ($state == 'enable') {
174 174
             session(['translation_live_mode' => true]);
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,16 +27,14 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
29 29
      */
30
-    public function index()
31
-    {
30
+    public function index() {
32 31
         $search = Input::get('search', '');
33 32
         $locale = Input::get('locale', '');
34 33
 
35 34
         $query = TranslationIdentifier::with('translations');
36 35
 
37 36
         if ($locale != '') {
38
-            $query = $query->whereDoesntHave('translations', function ($query) use ($locale)
39
-                {
37
+            $query = $query->whereDoesntHave('translations', function ($query) use ($locale) {
40 38
                     $query->where('translations.locale', 'like', $locale);
41 39
                 }
42 40
             );
@@ -73,8 +71,7 @@  discard block
 block discarded – undo
73 71
      * @param integer $id ID of the translation Identifier to edit
74 72
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
75 73
      */
76
-    public function edit($id)
77
-    {
74
+    public function edit($id) {
78 75
         $identifier = TranslationIdentifier::findOrFail($id);
79 76
 
80 77
         $available_locales = TranslatorFacade::getConfigValue('available_locales');
@@ -97,8 +94,7 @@  discard block
 block discarded – undo
97 94
      * @param Request $request Object with the values of the identifier
98 95
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
99 96
      */
100
-    public function postEdit($id, Request $request)
101
-    {
97
+    public function postEdit($id, Request $request) {
102 98
         TranslationIdentifier::findOrFail($id);
103 99
 
104 100
         foreach ($request->all() as $key => $value) {
@@ -131,8 +127,7 @@  discard block
 block discarded – undo
131 127
      * @param Request $request Request with multiple values of identifiers to update
132 128
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
133 129
      */
134
-    public function postIdentifier(Request $request)
135
-    {
130
+    public function postIdentifier(Request $request) {
136 131
         /** @var TranslationIdentifier $translation_identifiers */
137 132
         $translation_identifiers = TranslationIdentifier::all()->whereIn('id', array_keys($request->all()));
138 133
 
@@ -159,8 +154,7 @@  discard block
 block discarded – undo
159 154
      *
160 155
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
161 156
      */
162
-    public function test()
163
-    {
157
+    public function test() {
164 158
         return view('translator::test');
165 159
     }
166 160
 
@@ -168,8 +162,7 @@  discard block
 block discarded – undo
168 162
      * @param $state string 'enabled|disabled'
169 163
      * @return \Illuminate\Http\RedirectResponse
170 164
      */
171
-    public function changeLiveMode ($state)
172
-    {
165
+    public function changeLiveMode ($state) {
173 166
         if ($state == 'enable') {
174 167
             session(['translation_live_mode' => true]);
175 168
         } else {
Please login to merge, or discard this patch.
src/Middleware/TranslatorMiddleware.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@
 block discarded – undo
30 30
      *
31 31
      * @todo Validate Browser locale string (https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4)
32 32
      */
33
-    public function handle(Request $request, Closure $next)
34
-    {
33
+    public function handle(Request $request, Closure $next) {
35 34
         if (Session::has('locale') || auth()->check()) {
36 35
             $locale = Session::has('locale') ? session()->get('locale') : auth()->user()->language;
37 36
 
Please login to merge, or discard this patch.