Completed
Push — master ( 176f0f...1075fd )
by Avtandil
12:11
created
src/MultiLang/Console/ExportCommand.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
         $this->db = $this->getDatabase();
85 85
 
86 86
         $lang = $this->option('lang');
87
-        if (! empty($lang)) {
87
+        if (!empty($lang)) {
88 88
             $this->langs = explode(',', $lang);
89 89
         }
90 90
 
91 91
         $scopes = $this->scopes;
92 92
         $scope = $this->option('scope');
93
-        if (! empty($scope)) {
93
+        if (!empty($scope)) {
94 94
             $scopes = explode(',', $scope);
95 95
             foreach ($scopes as $scope) {
96
-                if (! in_array($scope, $this->scopes)) {
96
+                if (!in_array($scope, $this->scopes)) {
97 97
                     throw new InvalidArgumentException('Scope "' . $scope . '" is not found! Available scopes is ' . implode(', ', $this->scopes));
98 98
                 }
99 99
             }
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 
102 102
         $path = $this->option('path', 'storage/multilang');
103 103
         $this->path = base_path($path);
104
-        if (! is_dir($this->path)) {
105
-            if (! mkdir($this->path, 0777, true)) {
104
+        if (!is_dir($this->path)) {
105
+            if (!mkdir($this->path, 0777, true)) {
106 106
                 throw new InvalidArgumentException('unable to create the folder "' . $this->path . '"!');
107 107
             }
108 108
         }
109
-        if (! is_writable($this->path)) {
109
+        if (!is_writable($this->path)) {
110 110
             throw new InvalidArgumentException('Folder "' . $this->path . '" is not writable!');
111 111
         }
112 112
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     {
150 150
         $dbTexts = $this->getTextsFromDb($scope);
151 151
 
152
-        $fileTexts = ! $clear ? $this->getTextsFromFile($scope) : [];
152
+        $fileTexts = !$clear ? $this->getTextsFromFile($scope) : [];
153 153
 
154 154
         $textsToWrite = $force ? array_replace_recursive($fileTexts, $dbTexts) : array_replace_recursive($dbTexts, $fileTexts);
155 155
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
         $path = $this->path . '/' . $scope . '.yml';
162 162
         $written = file_put_contents($path, $yaml);
163
-        if (! $written) {
163
+        if (!$written) {
164 164
             $this->error('Export texts of "' . $scope . '" is failed!');
165 165
         }
166 166
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         foreach ($dbTexts as $text) {
205 205
             $key = $text->key;
206 206
             $lang = $text->lang;
207
-            if (! isset($formattedDbTexts[$key])) {
207
+            if (!isset($formattedDbTexts[$key])) {
208 208
                 $formattedDbTexts[$key] = ['key' => $key];
209 209
             }
210 210
             $formattedDbTexts[$key]['texts'][$lang] = $text->value;
Please login to merge, or discard this patch.
src/MultiLang/Console/MigrationCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
 
92 92
         $data = str_replace('{{TEXTS_TABLE}}', $table, $content);
93 93
 
94
-        if (! file_put_contents($migrationFile, $data)) {
94
+        if (!file_put_contents($migrationFile, $data)) {
95 95
             return false;
96 96
         }
97 97
 
Please login to merge, or discard this patch.
src/MultiLang/Models/LocalizableScope.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public function apply(Builder $builder, Model $model)
21 21
     {
22 22
 
23
-        if (! $this->queryHasLocalizableColumn($builder)) {
23
+        if (!$this->queryHasLocalizableColumn($builder)) {
24 24
             $builder->where($model->getQualifiedLocalizableColumn(), '=', app()->getLocale());
25 25
         }
26 26
     }
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $wheres = $builder->getQuery()->wheres;
37 37
         $column = $this->getLocalizableColumn($builder);
38
-        if (! empty($wheres)) {
38
+        if (!empty($wheres)) {
39 39
             foreach ($wheres as $where) {
40 40
                 if (isset($where['column']) && $where['column'] === $column) {
41 41
                     return true;
Please login to merge, or discard this patch.
src/MultiLang/MultiLangServiceProvider.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -38,18 +38,18 @@  discard block
 block discarded – undo
38 38
         );
39 39
 
40 40
         // Register blade directives
41
-        $this->getBlade()->directive('t', static function ($expression) {
41
+        $this->getBlade()->directive('t', static function($expression) {
42 42
             return "<?php echo e(t({$expression})); ?>";
43 43
         });
44 44
 
45
-        $this->app['events']->listen(RouteMatched::class, function () {
45
+        $this->app['events']->listen(RouteMatched::class, function() {
46 46
             $scope = $this->app['config']->get('app.scope');
47 47
             if ($scope && $scope !== 'global') {
48 48
                 $this->app['multilang']->setScope($scope);
49 49
             }
50 50
         });
51 51
 
52
-        $this->app['events']->listen(LocaleUpdated::class, function ($event) {
52
+        $this->app['events']->listen(LocaleUpdated::class, function($event) {
53 53
             $this->app['multilang']->setLocale($event->locale);
54 54
         });
55 55
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $configPath = __DIR__ . '/../config/config.php';
67 67
         $this->mergeConfigFrom($configPath, 'multilang');
68 68
 
69
-        $this->app->singleton('multilang', function ($app) {
69
+        $this->app->singleton('multilang', function($app) {
70 70
             $environment = $app->environment();
71 71
             $config = $app['config']->get('multilang');
72 72
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
             );
79 79
 
80 80
             if ($multilang->autoSaveIsAllowed()) {
81
-                $app->terminating(function () use ($multilang) {
81
+                $app->terminating(function() use ($multilang) {
82 82
                     $scope = $this->app['config']->get('app.scope');
83 83
                     if ($scope && $scope !== 'global') {
84 84
                         $multilang->setScope($scope);
@@ -95,28 +95,28 @@  discard block
 block discarded – undo
95 95
 
96 96
         $this->app->singleton(
97 97
             'command.multilang.migration',
98
-            static function () {
98
+            static function() {
99 99
                 return new MigrationCommand();
100 100
             }
101 101
         );
102 102
 
103 103
         $this->app->singleton(
104 104
             'command.multilang.texts',
105
-            static function () {
105
+            static function() {
106 106
                 return new TextsCommand();
107 107
             }
108 108
         );
109 109
 
110 110
         $this->app->singleton(
111 111
             'command.multilang.import',
112
-            static function () {
112
+            static function() {
113 113
                 return new ImportCommand();
114 114
             }
115 115
         );
116 116
 
117 117
         $this->app->singleton(
118 118
             'command.multilang.export',
119
-            static function () {
119
+            static function() {
120 120
                 return new ExportCommand();
121 121
             }
122 122
         );
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             ]
131 131
         );
132 132
 
133
-        $this->app->make('request')->macro('locale', static function () {
133
+        $this->app->make('request')->macro('locale', static function() {
134 134
             return app('multilang')->getLocale();
135 135
         });
136 136
     }
Please login to merge, or discard this patch.
src/MultiLang/Repository.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     public function getCacheName(string $lang, ?string $scope = null): string
58 58
     {
59 59
         $key = $this->config->get('db.texts_table', 'texts') . '_' . $lang;
60
-        if (! is_null($scope)) {
60
+        if (!is_null($scope)) {
61 61
             $key .= '_' . $scope;
62 62
         }
63 63
 
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
         $query = $this->getDb()->table($this->getTableName())
77 77
             ->where('lang', $lang);
78 78
 
79
-        if (! is_null($scope) && $scope !== 'global') {
80
-            $query = $query->whereNested(static function ($query) use ($scope) {
79
+        if (!is_null($scope) && $scope !== 'global') {
80
+            $query = $query->whereNested(static function($query) use ($scope) {
81 81
                 $query->where('scope', 'global');
82 82
                 $query->orWhere('scope', $scope);
83 83
             });
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $query = $this->getDb()->table($this->getTableName());
108 108
 
109
-        if (! is_null($lang)) {
109
+        if (!is_null($lang)) {
110 110
             $query = $query->where('lang', $lang);
111 111
         }
112 112
 
113
-        if (! is_null($scope)) {
114
-            $query = $query->whereNested(static function ($query) use ($scope) {
113
+        if (!is_null($scope)) {
114
+            $query = $query->whereNested(static function($query) use ($scope) {
115 115
                 $query->where('scope', 'global');
116 116
                 $query->orWhere('scope', $scope);
117 117
             });
Please login to merge, or discard this patch.
src/MultiLang/Console/ImportCommand.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
         $this->db = $this->getDatabase();
81 81
 
82 82
         $lang = $this->option('lang');
83
-        if (! empty($lang)) {
83
+        if (!empty($lang)) {
84 84
             $this->langs = explode(',', $lang);
85 85
         }
86 86
 
87 87
         $scopes = $this->scopes;
88 88
         $scope = $this->option('scope');
89
-        if (! empty($scope)) {
89
+        if (!empty($scope)) {
90 90
             $scopes = explode(',', $scope);
91 91
             foreach ($scopes as $scope) {
92
-                if (! in_array($scope, $this->scopes)) {
92
+                if (!in_array($scope, $this->scopes)) {
93 93
                     throw new InvalidArgumentException('Scope "' . $scope . '" is not found! Available scopes is ' . implode(', ', $this->scopes));
94 94
                 }
95 95
             }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
         $path = $this->option('path', 'storage/multilang');
99 99
         $this->path = base_path($path);
100
-        if (! is_dir($this->path)) {
100
+        if (!is_dir($this->path)) {
101 101
             throw new InvalidArgumentException('Folder "' . $this->path . '" is not accessible!');
102 102
         }
103 103
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     protected function import(string $scope = 'global', bool $force = false, bool $clear = false)
112 112
     {
113 113
         $path = $this->path . '/' . $scope . '.yml';
114
-        if (! is_readable($path)) {
114
+        if (!is_readable($path)) {
115 115
             $this->warn('File "' . $path . '" is not readable!');
116 116
 
117 117
             return false;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             $key = $text['key'];
139 139
 
140 140
             foreach ($text['texts'] as $lang => $value) {
141
-                if (! empty($this->langs) && ! in_array($lang, $this->langs)) {
141
+                if (!empty($this->langs) && !in_array($lang, $this->langs)) {
142 142
                     continue;
143 143
                 }
144 144
 
Please login to merge, or discard this patch.
src/helpers.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 declare(strict_types=1);
4 4
 
5
-if (! function_exists('lang_url')) {
5
+if (!function_exists('lang_url')) {
6 6
     /**
7 7
      * Generate a url for the application.
8 8
      *
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     }
27 27
 }
28 28
 
29
-if (! function_exists('lang_redirect')) {
29
+if (!function_exists('lang_redirect')) {
30 30
     /**
31 31
      * Get an instance of the redirector.
32 32
      *
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     }
51 51
 }
52 52
 
53
-if (! function_exists('lang_route')) {
53
+if (!function_exists('lang_route')) {
54 54
     /**
55 55
      * Get route by name
56 56
      *
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     }
70 70
 }
71 71
 
72
-if (! function_exists('t')) {
72
+if (!function_exists('t')) {
73 73
     /**
74 74
      * Get translated text
75 75
      *
Please login to merge, or discard this patch.
src/MultiLang/MultiLang.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      */
178 178
     public function setLocale(string $lang)
179 179
     {
180
-        if (! $lang) {
180
+        if (!$lang) {
181 181
             throw new InvalidArgumentException('Locale is empty');
182 182
         }
183 183
         $this->lang = $lang;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      */
221 221
     public function get(string $key, array $replacements = []): string
222 222
     {
223
-        if (! $this->getConfig()->get('use_texts', true)) {
223
+        if (!$this->getConfig()->get('use_texts', true)) {
224 224
             throw new InvalidArgumentException('Using texts from database is disabled in config');
225 225
         }
226 226
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
             throw new InvalidArgumentException('Text key not provided');
229 229
         }
230 230
 
231
-        if (! $this->lang) {
231
+        if (!$this->lang) {
232 232
             return $key;
233 233
         }
234 234
 
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
             $this->loadTexts();
238 238
         }
239 239
 
240
-        if (! isset($this->texts[$key])) {
240
+        if (!isset($this->texts[$key])) {
241 241
             $this->queueToSave($key);
242 242
         }
243 243
 
244
-        if (! empty($replacements)) {
244
+        if (!empty($replacements)) {
245 245
             $keys = array_keys($replacements);
246
-            $keys = array_map(static function ($v) {
246
+            $keys = array_map(static function($v) {
247 247
                 return ':' . $v;
248 248
             }, $keys);
249 249
             $replacements = array_combine($keys, $replacements);
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     public function getRedirectUrl(Request $request): string
262 262
     {
263 263
         $excludePatterns = $this->config->get('exclude_segments', []);
264
-        if (! empty($excludePatterns)) {
264
+        if (!empty($excludePatterns)) {
265 265
             if (call_user_func_array([$request, 'is'], $excludePatterns)) {
266 266
                 return '';
267 267
             }
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
 
270 270
         $locale = $request->segment(1);
271 271
         $fallbackLocale = $this->config->get('default_locale', 'en');
272
-        if (! empty($locale) && strlen($locale) === 2) {
272
+        if (!empty($locale) && strlen($locale) === 2) {
273 273
             $locales = $this->config->get('locales', []);
274 274
 
275
-            if (! isset($locales[$locale])) {
275
+            if (!isset($locales[$locale])) {
276 276
                 $segments = $request->segments();
277 277
                 $segments[0] = $fallbackLocale;
278 278
                 $url = implode('/', $segments);
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 
492 492
         // Remove domain from path
493 493
         $appUrl = config('app.url', '');
494
-        if (! empty($appUrl) && mb_substr($langPath, 0, mb_strlen($appUrl)) === $appUrl) {
494
+        if (!empty($appUrl) && mb_substr($langPath, 0, mb_strlen($appUrl)) === $appUrl) {
495 495
             $langPath = ltrim(str_replace($appUrl, '', $langPath), '/');
496 496
         }
497 497
 
Please login to merge, or discard this patch.
src/MultiLang/Middleware/MultiLang.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function handle(Request $request, Closure $next)
55 55
     {
56
-        if (! $this->app->bound(MultiLangLib::class)) {
56
+        if (!$this->app->bound(MultiLangLib::class)) {
57 57
             return $next($request);
58 58
         }
59 59
         $multilang = $this->app->make(MultiLangLib::class);
60 60
 
61 61
         $url = $multilang->getRedirectUrl($request);
62 62
 
63
-        if (! empty($url)) {
63
+        if (!empty($url)) {
64 64
             if ($request->expectsJson()) {
65 65
                 return response('Not found', 404);
66 66
             } else {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
         if ($multilang->getConfig()->get('set_system_locale')) {
80 80
             $locales = $multilang->getLocales();
81
-            if (! empty($locales[$locale]['full_locale'])) {
81
+            if (!empty($locales[$locale]['full_locale'])) {
82 82
                 $lc = $multilang->getConfig()->get('system_locale_lc', E_ALL);
83 83
 
84 84
                 setlocale($lc, $locales[$locale]['full_locale']);
Please login to merge, or discard this patch.