From a5e6722df7f22fe708fcad3dea2f35dc643f8d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Subotkevi=C4=8D?= Date: Wed, 7 Nov 2018 07:34:25 +0200 Subject: [PATCH] PSR-2 --- src/Command/TranslationHelperCommand.php | 34 +++++++++++++----------- src/helpers.php | 4 +-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/Command/TranslationHelperCommand.php b/src/Command/TranslationHelperCommand.php index 30e60a0..0ed7062 100644 --- a/src/Command/TranslationHelperCommand.php +++ b/src/Command/TranslationHelperCommand.php @@ -23,33 +23,35 @@ class TranslationHelperCommand extends Command */ public function handle() { - $translationKeys = $this->findProjectTranslationsKeys(); + $translationKeys = $this->findProjectTranslationsKeys(); $translationFiles = $this->getProjectTranslationFiles(); foreach ($translationFiles as $file) { $translationData = $this->getAlreadyTranslatedKeys($file); - $this->line("Language: " . str_replace('.json', '', basename($file))); - $added = []; + $added = []; + + $this->line('Language: ' . str_replace('.json', '', basename($file))); foreach ($translationKeys as $key) { if (!isset($translationData[$key])) { - $this->warn(" - Added: {$key}"); $translationData[$key] = ''; - $added[] = $key; + $added[] = $key; + + $this->warn(" - Added: {$key}"); } } if ($added) { - $this->line("Updating translation file..."); + $this->line('Updating translation file...'); $this->writeNewTranslationFile($file, $translationData); - $this->info("Translation file have been updated!"); + $this->info('Translation file have been updated!'); } else { - $this->warn("Nothing new found for this language."); + $this->warn('Nothing new found for this language.'); } - $this->line(""); + $this->line(''); } } @@ -58,11 +60,11 @@ public function handle() */ private function findProjectTranslationsKeys() { - $allKeys = []; + $allKeys = []; $viewsDirectories = config('translation-helper.scan_directories'); - $fileExtensions = config('translation-helper.file_extensions'); + $fileExtensions = config('translation-helper.file_extensions'); - foreach($viewsDirectories as $directory) { + foreach ($viewsDirectories as $directory) { foreach ($fileExtensions as $extension) { $this->getTranslationKeysFromDir($allKeys, $directory, $extension); } @@ -102,11 +104,11 @@ private function getTranslationKeysFromFunction(&$keys, $functionName, $content) preg_match_all("#{$functionName}\(\'(.*?)\'\)#", $content, $matches); - if ( ! empty($matches)) { + if (! empty($matches)) { foreach ($matches[1] as $match) { $match = str_replace('"', "'", str_replace("\'", "'", $match)); - if ( ! empty($match)) { + if (! empty($match)) { $keys[$match] = $match; } } @@ -118,7 +120,7 @@ private function getTranslationKeysFromFunction(&$keys, $functionName, $content) */ private function getProjectTranslationFiles() { - $path = config('translation-helper.output_directory'); + $path = config('translation-helper.output_directory'); $files = glob("{$path}/*.json", GLOB_BRACE); return $files; @@ -143,7 +145,7 @@ private function getAlreadyTranslatedKeys($filePath) */ private function writeNewTranslationFile($filePath, $translations) { - file_put_contents($filePath, json_encode($translations, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE)); + file_put_contents($filePath, json_encode($translations, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); } /** diff --git a/src/helpers.php b/src/helpers.php index 75bb56f..76e6991 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -1,6 +1,6 @@