Skip to content

Commit a5e6722

Browse files
committed
PSR-2
1 parent 6535055 commit a5e6722

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/Command/TranslationHelperCommand.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,35 @@ class TranslationHelperCommand extends Command
2323
*/
2424
public function handle()
2525
{
26-
$translationKeys = $this->findProjectTranslationsKeys();
26+
$translationKeys = $this->findProjectTranslationsKeys();
2727
$translationFiles = $this->getProjectTranslationFiles();
2828

2929
foreach ($translationFiles as $file) {
3030
$translationData = $this->getAlreadyTranslatedKeys($file);
31-
$this->line("Language: " . str_replace('.json', '', basename($file)));
32-
$added = [];
31+
$added = [];
32+
33+
$this->line('Language: ' . str_replace('.json', '', basename($file)));
3334

3435
foreach ($translationKeys as $key) {
3536
if (!isset($translationData[$key])) {
36-
$this->warn(" - Added: {$key}");
3737
$translationData[$key] = '';
38-
$added[] = $key;
38+
$added[] = $key;
39+
40+
$this->warn(" - Added: {$key}");
3941
}
4042
}
4143

4244
if ($added) {
43-
$this->line("Updating translation file...");
45+
$this->line('Updating translation file...');
4446

4547
$this->writeNewTranslationFile($file, $translationData);
4648

47-
$this->info("Translation file have been updated!");
49+
$this->info('Translation file have been updated!');
4850
} else {
49-
$this->warn("Nothing new found for this language.");
51+
$this->warn('Nothing new found for this language.');
5052
}
5153

52-
$this->line("");
54+
$this->line('');
5355
}
5456
}
5557

@@ -58,11 +60,11 @@ public function handle()
5860
*/
5961
private function findProjectTranslationsKeys()
6062
{
61-
$allKeys = [];
63+
$allKeys = [];
6264
$viewsDirectories = config('translation-helper.scan_directories');
63-
$fileExtensions = config('translation-helper.file_extensions');
65+
$fileExtensions = config('translation-helper.file_extensions');
6466

65-
foreach($viewsDirectories as $directory) {
67+
foreach ($viewsDirectories as $directory) {
6668
foreach ($fileExtensions as $extension) {
6769
$this->getTranslationKeysFromDir($allKeys, $directory, $extension);
6870
}
@@ -102,11 +104,11 @@ private function getTranslationKeysFromFunction(&$keys, $functionName, $content)
102104

103105
preg_match_all("#{$functionName}\(\'(.*?)\'\)#", $content, $matches);
104106

105-
if ( ! empty($matches)) {
107+
if (! empty($matches)) {
106108
foreach ($matches[1] as $match) {
107109
$match = str_replace('"', "'", str_replace("\'", "'", $match));
108110

109-
if ( ! empty($match)) {
111+
if (! empty($match)) {
110112
$keys[$match] = $match;
111113
}
112114
}
@@ -118,7 +120,7 @@ private function getTranslationKeysFromFunction(&$keys, $functionName, $content)
118120
*/
119121
private function getProjectTranslationFiles()
120122
{
121-
$path = config('translation-helper.output_directory');
123+
$path = config('translation-helper.output_directory');
122124
$files = glob("{$path}/*.json", GLOB_BRACE);
123125

124126
return $files;
@@ -143,7 +145,7 @@ private function getAlreadyTranslatedKeys($filePath)
143145
*/
144146
private function writeNewTranslationFile($filePath, $translations)
145147
{
146-
file_put_contents($filePath, json_encode($translations, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
148+
file_put_contents($filePath, json_encode($translations, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
147149
}
148150

149151
/**

src/helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if ( ! function_exists('lang')) {
3+
if (! function_exists('lang')) {
44
/**
55
* Translate the given message.
66
*
@@ -15,7 +15,7 @@ function lang($key = null, $replace = [], $locale = null)
1515
}
1616
}
1717

18-
if ( ! function_exists('glob_recursive')) {
18+
if (! function_exists('glob_recursive')) {
1919
/**
2020
* Find path names matching a pattern recursively
2121
*

0 commit comments

Comments
 (0)