@@ -42,9 +42,9 @@ public function allLanguages(): Collection
4242 */
4343 public function allGroup (string $ language ): Collection
4444 {
45- $ groupPath = "{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ language }" ;
45+ $ groupPath = "{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ language }" ;
4646
47- if (!$ this ->disk ->exists ($ groupPath )) {
47+ if (! $ this ->disk ->exists ($ groupPath )) {
4848 return [];
4949 }
5050
@@ -85,8 +85,8 @@ public function addLanguage(string $language, ?string $name = null): void
8585 throw new LanguageExistsException (__ ('translation::errors.language_exists ' , ['language ' => $ language ]));
8686 }
8787
88- $ this ->disk ->makeDirectory ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "$ language " );
89- if (!$ this ->disk ->exists ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ language }.json " )) {
88+ $ this ->disk ->makeDirectory ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "$ language " );
89+ if (! $ this ->disk ->exists ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ language }.json " )) {
9090 $ this ->saveSingleTranslations ($ language , collect (['single ' => collect ()]));
9191 }
9292 }
@@ -96,14 +96,14 @@ public function addLanguage(string $language, ?string $name = null): void
9696 */
9797 public function addGroupTranslation (string $ language , string $ group , string $ key , string $ value = '' ): void
9898 {
99- if (!$ this ->languageExists ($ language )) {
99+ if (! $ this ->languageExists ($ language )) {
100100 $ this ->addLanguage ($ language );
101101 }
102102
103103 $ translations = $ this ->getGroupTranslationsFor ($ language );
104104
105105 // does the group exist? If not, create it.
106- if (!$ translations ->keys ()->contains ($ group )) {
106+ if (! $ translations ->keys ()->contains ($ group )) {
107107 $ translations ->put ($ group , collect ());
108108 }
109109
@@ -119,7 +119,7 @@ public function addGroupTranslation(string $language, string $group, string $key
119119 */
120120 public function addSingleTranslation (string $ language , string $ vendor , string $ key , string $ value = '' ): void
121121 {
122- if (!$ this ->languageExists ($ language )) {
122+ if (! $ this ->languageExists ($ language )) {
123123 $ this ->addLanguage ($ language );
124124 }
125125
@@ -141,7 +141,7 @@ public function getSingleTranslationsFor(string $language): Collection
141141 return strpos ($ file , "{$ language }.json " );
142142 })->flatMap (function ($ file ) {
143143 if (strpos ($ file ->getPathname (), 'vendor ' )) {
144- $ vendor = Str::before (Str::after ($ file ->getPathname (), 'vendor ' . DIRECTORY_SEPARATOR ), DIRECTORY_SEPARATOR );
144+ $ vendor = Str::before (Str::after ($ file ->getPathname (), 'vendor ' . DIRECTORY_SEPARATOR ), DIRECTORY_SEPARATOR );
145145
146146 return ["{$ vendor }::single " => new Collection (json_decode ($ this ->disk ->get ($ file ), true ))];
147147 }
@@ -159,7 +159,7 @@ public function getGroupTranslationsFor(string $language): Collection
159159 // here we check if the path contains 'vendor' as these will be the
160160 // files which need namespacing
161161 if (Str::contains ($ group ->getPathname (), 'vendor ' )) {
162- $ vendor = Str::before (Str::after ($ group ->getPathname (), 'vendor ' . DIRECTORY_SEPARATOR ), DIRECTORY_SEPARATOR );
162+ $ vendor = Str::before (Str::after ($ group ->getPathname (), 'vendor ' . DIRECTORY_SEPARATOR ), DIRECTORY_SEPARATOR );
163163
164164 return ["{$ vendor }:: {$ group ->getBasename ('.php ' )}" => new Collection ($ this ->disk ->getRequire ($ group ->getPathname ()))];
165165 }
@@ -183,7 +183,7 @@ public function getGroupsFor(string $language): Collection
183183 {
184184 return $ this ->getGroupFilesFor ($ language )->map (function ($ file ) {
185185 if (Str::contains ($ file ->getPathname (), 'vendor ' )) {
186- $ vendor = Str::before (Str::after ($ file ->getPathname (), 'vendor ' . DIRECTORY_SEPARATOR ), DIRECTORY_SEPARATOR );
186+ $ vendor = Str::before (Str::after ($ file ->getPathname (), 'vendor ' . DIRECTORY_SEPARATOR ), DIRECTORY_SEPARATOR );
187187
188188 return "{$ vendor }:: {$ file ->getBasename ('.php ' )}" ;
189189 }
@@ -198,7 +198,7 @@ public function getGroupsFor(string $language): Collection
198198 public function getTranslationsForFile (string $ language , string $ file ): Collection
199199 {
200200 $ file = Str::finish ($ file , '.php ' );
201- $ filePath = "{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ language }" . DIRECTORY_SEPARATOR . "{$ file }" ;
201+ $ filePath = "{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ language }" . DIRECTORY_SEPARATOR . "{$ file }" ;
202202 $ translations = new Collection ;
203203
204204 if ($ this ->disk ->exists ($ filePath )) {
@@ -228,7 +228,7 @@ public function saveGroupTranslations(string $language, string $group, Collectio
228228
229229 return ;
230230 }
231- $ this ->disk ->put ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ language }" . DIRECTORY_SEPARATOR . "{$ group }.php " , "<?php \n\nreturn " . var_export ($ translations ->toArray (), true ) . '; ' . \PHP_EOL );
231+ $ this ->disk ->put ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ language }" . DIRECTORY_SEPARATOR . "{$ group }.php " , "<?php \n\nreturn " . var_export ($ translations ->toArray (), true ). '; ' . \PHP_EOL );
232232 }
233233
234234 /**
@@ -237,13 +237,13 @@ public function saveGroupTranslations(string $language, string $group, Collectio
237237 private function saveNamespacedGroupTranslations (string $ language , string $ group , Collection $ translations ): void
238238 {
239239 [$ namespace , $ group ] = explode (':: ' , $ group );
240- $ directory = "{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . 'vendor ' . DIRECTORY_SEPARATOR . "{$ namespace }" . DIRECTORY_SEPARATOR . "{$ language }" ;
240+ $ directory = "{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . 'vendor ' . DIRECTORY_SEPARATOR . "{$ namespace }" . DIRECTORY_SEPARATOR . "{$ language }" ;
241241
242- if (!$ this ->disk ->exists ($ directory )) {
242+ if (! $ this ->disk ->exists ($ directory )) {
243243 $ this ->disk ->makeDirectory ($ directory , 0755 , true );
244244 }
245245
246- $ this ->disk ->put ("$ directory " . DIRECTORY_SEPARATOR . "{$ group }.php " , "<?php \n\nreturn " . var_export ($ translations ->toArray (), true ) . '; ' . \PHP_EOL );
246+ $ this ->disk ->put ("$ directory " . DIRECTORY_SEPARATOR . "{$ group }.php " , "<?php \n\nreturn " . var_export ($ translations ->toArray (), true ). '; ' . \PHP_EOL );
247247 }
248248
249249 /**
@@ -253,9 +253,9 @@ private function saveSingleTranslations(string $language, Collection $translatio
253253 {
254254 foreach ($ translations as $ group => $ translation ) {
255255 $ vendor = Str::before ($ group , '::single ' );
256- $ languageFilePath = $ vendor !== 'single ' ? 'vendor ' . DIRECTORY_SEPARATOR . "{$ vendor }" . DIRECTORY_SEPARATOR . "{$ language }.json " : "{$ language }.json " ;
256+ $ languageFilePath = $ vendor !== 'single ' ? 'vendor ' . DIRECTORY_SEPARATOR . "{$ vendor }" . DIRECTORY_SEPARATOR . "{$ language }.json " : "{$ language }.json " ;
257257 $ this ->disk ->put (
258- "{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ languageFilePath }" ,
258+ "{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ languageFilePath }" ,
259259 json_encode ((object ) $ translations ->get ($ group ), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT )
260260 );
261261 }
@@ -266,7 +266,7 @@ private function saveSingleTranslations(string $language, Collection $translatio
266266 */
267267 public function getGroupFilesFor (string $ language ): Collection
268268 {
269- $ groups = new Collection ($ this ->disk ->allFiles ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ language }" ));
269+ $ groups = new Collection ($ this ->disk ->allFiles ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . "{$ language }" ));
270270 // namespaced files reside in the vendor directory so we'll grab these
271271 // the `getVendorGroupFileFor` method
272272 $ groups = $ groups ->merge ($ this ->getVendorGroupFilesFor ($ language ));
@@ -279,17 +279,17 @@ public function getGroupFilesFor(string $language): Collection
279279 */
280280 public function getVendorGroupFilesFor (string $ language ): ?Collection
281281 {
282- if (!$ this ->disk ->exists ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . 'vendor ' )) {
282+ if (! $ this ->disk ->exists ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . 'vendor ' )) {
283283 return null ;
284284 }
285285
286286 $ vendorGroups = [];
287- foreach ($ this ->disk ->directories ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . 'vendor ' ) as $ vendor ) {
287+ foreach ($ this ->disk ->directories ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . 'vendor ' ) as $ vendor ) {
288288 $ vendor = Arr::last (explode (DIRECTORY_SEPARATOR , $ vendor ));
289- if (!$ this ->disk ->exists ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . 'vendor ' . DIRECTORY_SEPARATOR . "{$ vendor }" . DIRECTORY_SEPARATOR . "{$ language }" )) {
289+ if (! $ this ->disk ->exists ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . 'vendor ' . DIRECTORY_SEPARATOR . "{$ vendor }" . DIRECTORY_SEPARATOR . "{$ language }" )) {
290290 array_push ($ vendorGroups , []);
291291 } else {
292- array_push ($ vendorGroups , $ this ->disk ->allFiles ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . 'vendor ' . DIRECTORY_SEPARATOR . "{$ vendor }" . DIRECTORY_SEPARATOR . "{$ language }" ));
292+ array_push ($ vendorGroups , $ this ->disk ->allFiles ("{$ this ->languageFilesPath }" . DIRECTORY_SEPARATOR . 'vendor ' . DIRECTORY_SEPARATOR . "{$ vendor }" . DIRECTORY_SEPARATOR . "{$ language }" ));
293293 }
294294 }
295295
0 commit comments