Skip to content

Commit 0a2b4e8

Browse files
joedixonStyleCIBot
andauthored
Apply fixes from StyleCI (#232)
[ci skip] [skip ci] Co-authored-by: StyleCI Bot <bot@styleci.io>
1 parent 931265c commit 0a2b4e8

File tree

8 files changed

+59
-59
lines changed

8 files changed

+59
-59
lines changed

src/Console/Commands/ListMissingTranslationKeys.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function handle()
2020
// check whether or not there are any missing translations
2121
$empty = true;
2222
foreach ($missingTranslations as $language => $values) {
23-
if (!empty($values)) {
23+
if (! empty($values)) {
2424
$empty = false;
2525
}
2626
}

src/Console/Commands/SynchroniseTranslations.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function handle()
4444
else {
4545
$this->fromDriver = $this->anticipate(__('translation::translation.prompt_from_driver'), $this->drivers);
4646

47-
if (!in_array($this->fromDriver, $this->drivers)) {
47+
if (! in_array($this->fromDriver, $this->drivers)) {
4848
return $this->error(__('translation::translation.invalid_driver'));
4949
}
5050
}
@@ -61,7 +61,7 @@ public function handle()
6161
else {
6262
$this->toDriver = $this->anticipate(__('translation::translation.prompt_to_driver'), $this->drivers);
6363

64-
if (!in_array($this->toDriver, $this->drivers)) {
64+
if (! in_array($this->toDriver, $this->drivers)) {
6565
return $this->error(__('translation::translation.invalid_driver'));
6666
}
6767
}
@@ -86,7 +86,7 @@ public function handle()
8686
else {
8787
$language = $this->anticipate(__('translation::translation.prompt_language_if_any'), $languages);
8888

89-
if ($language && !in_array($language, $languages)) {
89+
if ($language && ! in_array($language, $languages)) {
9090
return $this->error(__('translation::translation.invalid_language'));
9191
}
9292
}

src/Database/Factories/TranslationFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace JoeDixon\Translation\Database\Factories;
44

5-
use JoeDixon\Translation\Language;
65
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use JoeDixon\Translation\Language;
77
use JoeDixon\Translation\Translation;
88

99
class TranslationFactory extends Factory

src/Drivers/Database.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function addLanguage(string $language, ?string $name = null): void
7777
*/
7878
public function addGroupTranslation($language, $group, $key, $value = ''): void
7979
{
80-
if (!$this->languageExists($language)) {
80+
if (! $this->languageExists($language)) {
8181
$this->addLanguage($language);
8282
}
8383

@@ -99,7 +99,7 @@ public function addGroupTranslation($language, $group, $key, $value = ''): void
9999
*/
100100
public function addSingleTranslation($language, $vendor, $key, $value = ''): void
101101
{
102-
if (!$this->languageExists($language)) {
102+
if (! $this->languageExists($language)) {
103103
$this->addLanguage($language);
104104
}
105105

src/Drivers/File.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/Drivers/Translation.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,57 +13,57 @@ abstract class Translation
1313
/**
1414
* Get all languages.
1515
*/
16-
public abstract function allLanguages(): Collection;
16+
abstract public function allLanguages(): Collection;
1717

1818
/**
1919
* Get all translations.
2020
*/
21-
public abstract function allTranslations(): Collection;
21+
abstract public function allTranslations(): Collection;
2222

2323
/**
2424
* Get all group translations for a given language.
2525
*/
26-
public abstract function allGroup(string $language): Collection;
26+
abstract public function allGroup(string $language): Collection;
2727

2828
/**
2929
* Get all translations for a given language.
3030
*/
31-
public abstract function allTranslationsFor(string $language): Collection;
31+
abstract public function allTranslationsFor(string $language): Collection;
3232

3333
/**
3434
* Add a new language.
3535
*/
36-
public abstract function addLanguage(string $language, ?string $name = null): void;
36+
abstract public function addLanguage(string $language, ?string $name = null): void;
3737

3838
/**
3939
* Add a group translation.
4040
*/
41-
public abstract function addGroupTranslation(string $language, string $group, string $key, string $value = ''): void;
41+
abstract public function addGroupTranslation(string $language, string $group, string $key, string $value = ''): void;
4242

4343
/**
4444
* Add a single translation.
4545
*/
46-
public abstract function addSingleTranslation(string $language, string $vendor, string $key, string $value = ''): void;
46+
abstract public function addSingleTranslation(string $language, string $vendor, string $key, string $value = ''): void;
4747

4848
/**
4949
* Get single translations for a given language.
5050
*/
51-
public abstract function getSingleTranslationsFor(string $language): Collection;
51+
abstract public function getSingleTranslationsFor(string $language): Collection;
5252

5353
/**
5454
* Get group translations for a given language.
5555
*/
56-
public abstract function getGroupTranslationsFor(string $language): Collection;
56+
abstract public function getGroupTranslationsFor(string $language): Collection;
5757

5858
/**
5959
* Determine whether the given language exists.
6060
*/
61-
public abstract function languageExists(string $language): bool;
61+
abstract public function languageExists(string $language): bool;
6262

6363
/**
6464
* Get all the groups for a given language.
6565
*/
66-
public abstract function getGroupsFor(string $language): Collection;
66+
abstract public function getGroupsFor(string $language): Collection;
6767

6868
/**
6969
* Find all of the translations in the app without translation for a given language.
@@ -131,7 +131,7 @@ public function getSourceLanguageTranslationsWith(string $language): Collection
131131
public function filterTranslationsFor(string $language, ?string $filter): Collection
132132
{
133133
$allTranslations = $this->getSourceLanguageTranslationsWith(($language));
134-
if (!$filter) {
134+
if (! $filter) {
135135
return $allTranslations;
136136
}
137137

@@ -149,7 +149,7 @@ public function filterTranslationsFor(string $language, ?string $filter): Collec
149149
public function add(Request $request, $language, $isGroupTranslation)
150150
{
151151
$namespace = $request->has('namespace') && $request->get('namespace') ? "{$request->get('namespace')}::" : '';
152-
$group = $namespace . $request->get('group');
152+
$group = $namespace.$request->get('group');
153153
$key = $request->get('key');
154154
$value = $request->get('value') ?: '';
155155

src/TranslationServiceProvider.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ public function register()
5757
*/
5858
private function loadViews()
5959
{
60-
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'translation');
60+
$this->loadViewsFrom(__DIR__.'/../resources/views', 'translation');
6161

6262
$this->publishes([
63-
__DIR__ . '/../resources/views' => resource_path('views/vendor/translation'),
63+
__DIR__.'/../resources/views' => resource_path('views/vendor/translation'),
6464
]);
6565
}
6666

@@ -71,7 +71,7 @@ private function loadViews()
7171
*/
7272
private function registerRoutes()
7373
{
74-
$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
74+
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
7575
}
7676

7777
/**
@@ -82,7 +82,7 @@ private function registerRoutes()
8282
private function publishConfiguration()
8383
{
8484
$this->publishes([
85-
__DIR__ . '/../config/translation.php' => config_path('translation.php'),
85+
__DIR__.'/../config/translation.php' => config_path('translation.php'),
8686
], 'config');
8787
}
8888

@@ -93,7 +93,7 @@ private function publishConfiguration()
9393
*/
9494
private function mergeConfiguration()
9595
{
96-
$this->mergeConfigFrom(__DIR__ . '/../config/translation.php', 'translation');
96+
$this->mergeConfigFrom(__DIR__.'/../config/translation.php', 'translation');
9797
}
9898

9999
/**
@@ -104,7 +104,7 @@ private function mergeConfiguration()
104104
private function publishAssets()
105105
{
106106
$this->publishes([
107-
__DIR__ . '/../public/assets' => public_path('vendor/translation'),
107+
__DIR__.'/../public/assets' => public_path('vendor/translation'),
108108
], 'assets');
109109
}
110110

@@ -119,7 +119,7 @@ private function loadMigrations()
119119
return;
120120
}
121121

122-
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
122+
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
123123
}
124124

125125
/**
@@ -129,10 +129,10 @@ private function loadMigrations()
129129
*/
130130
private function loadTranslations()
131131
{
132-
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'translation');
132+
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'translation');
133133

134134
$this->publishes([
135-
__DIR__ . '/../resources/lang' => resource_path('lang/vendor/translation'),
135+
__DIR__.'/../resources/lang' => resource_path('lang/vendor/translation'),
136136
]);
137137
}
138138

@@ -162,7 +162,7 @@ private function registerCommands()
162162
*/
163163
private function registerHelpers()
164164
{
165-
require __DIR__ . '/../resources/helpers.php';
165+
require __DIR__.'/../resources/helpers.php';
166166
}
167167

168168
/**

0 commit comments

Comments
 (0)