Passed
Branch master (06ad6f)
by Alexander
22:27
created
src/Commands/SearchTranslationsCommand.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * Class SearchTranslationsCommand
22 22
  * @package App\Console\Commands
23 23
  */
24
-class SearchTranslationsCommand extends Command{
24
+class SearchTranslationsCommand extends Command {
25 25
     /**
26 26
      * The name and signature of the console command.
27 27
      *
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     /**
48 48
      * Create a new command instance.
49 49
      */
50
-    public function __construct(){
50
+    public function __construct() {
51 51
         parent::__construct();
52 52
     }
53 53
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @return mixed
58 58
      * @throws \Exception
59 59
      */
60
-    public function handle(){
60
+    public function handle() {
61 61
 
62 62
         // Get start time
63 63
         $start = microtime(true);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             'js'        => '/\$filter\(\'translate\'\)\(\'(?\'identifier\'.*?)\'\)/'
80 80
         ];
81 81
 
82
-        foreach($folders as $folder){
82
+        foreach ($folders as $folder) {
83 83
             $aFiles = array_merge($aFiles, File::allFiles(base_path().'/'.$folder));
84 84
         }
85 85
 
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 
96 96
             $extension = $file->getExtension();
97 97
 
98
-            if(in_array($extension, $valid_extensions)){
98
+            if (in_array($extension, $valid_extensions)) {
99 99
                 $content = file_get_contents($file);
100 100
 
101 101
                 foreach ($regexes as $key => $regex) {
102 102
                     preg_match_all($regex, $content, $result, PREG_SET_ORDER);
103 103
 
104
-                    if(!empty($result[0])){
104
+                    if (!empty($result[0])) {
105 105
                         $this->addMissing($result, $key);
106 106
                     }
107 107
                 }
@@ -113,23 +113,23 @@  discard block
 block discarded – undo
113 113
         $this->line('');
114 114
         $this->line('');
115 115
 
116
-        $this->table(['Num', 'Translations...'],[
116
+        $this->table(['Num', 'Translations...'], [
117 117
             [$this->found_identifier, "Found"],
118
-            [$this->new_identifier,   "New"],
119
-            [$this->dupl_identifier,  "Duplicates"],
118
+            [$this->new_identifier, "New"],
119
+            [$this->dupl_identifier, "Duplicates"],
120 120
             [$this->found_parameters, "With Parameters"],
121
-            [$this->found_invalid,    "Invalid"],
121
+            [$this->found_invalid, "Invalid"],
122 122
         ]);
123 123
 
124 124
         $this->line('');
125 125
 
126
-        $this->info('Finished in: ' . number_format(microtime(true) - $start, 2) . 'sec');
126
+        $this->info('Finished in: '.number_format(microtime(true) - $start, 2).'sec');
127 127
     }
128 128
 
129 129
     private function addMissing($result, $group) {
130 130
 
131 131
         foreach ($result as $item) {
132
-            try{
132
+            try {
133 133
 
134 134
                 $identifier = trim($item['identifier']);
135 135
                 $this->found_identifier++;
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
 
141 141
                     $parameter_string = $item['parameters'];
142 142
 
143
-                    if (substr($parameter_string, 0, 1 ) === '[') {
143
+                    if (substr($parameter_string, 0, 1) === '[') {
144 144
                         $parameter_string = substr($parameter_string, 1, -1);
145 145
                     }
146 146
 
147
-                    $parameter_array = explode(",",$parameter_string);
147
+                    $parameter_array = explode(",", $parameter_string);
148 148
 
149 149
                     $parameters = array();
150
-                    foreach($parameter_array as $parameter )
150
+                    foreach ($parameter_array as $parameter)
151 151
                     {
152
-                        $parameter = explode("=>",$parameter);
152
+                        $parameter = explode("=>", $parameter);
153 153
 
154
-                        $key = str_replace([" ", "'"],"", $parameter[0]);
155
-                        $value = str_replace([" ", "'"],"", $parameter[1]);
154
+                        $key = str_replace([" ", "'"], "", $parameter[0]);
155
+                        $value = str_replace([" ", "'"], "", $parameter[1]);
156 156
 
157 157
                         $parameters[$key] = $value;
158 158
                     }
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
                     $this->found_parameters++;
161 161
                 }
162 162
 
163
-                if(!isset($aTranslations[$identifier])){
163
+                if (!isset($aTranslations[$identifier])) {
164 164
                     $aTranslations[$identifier] = TranslatorFacade::hasIdentifier($identifier);
165 165
 
166
-                    if (! $aTranslations[$identifier]) {
166
+                    if (!$aTranslations[$identifier]) {
167 167
                         TranslatorFacade::addMissingIdentifier($identifier, $parameters, $group);
168 168
                         $this->bar->clear();
169 169
                         $this->info('Adding: "'.$identifier.'" to database');
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
                     $this->dupl_identifier++;
176 176
                 }
177 177
 
178
-            }catch(\Exception $e){
178
+            } catch (\Exception $e) {
179 179
                 $this->bar->clear();
180 180
                 $this->info($identifier.' '.strlen($identifier));
181 181
                 $this->info($e->getMessage());
Please login to merge, or discard this patch.
Braces   +12 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
  * Class SearchTranslationsCommand
22 22
  * @package App\Console\Commands
23 23
  */
24
-class SearchTranslationsCommand extends Command{
24
+class SearchTranslationsCommand extends Command
25
+{
25 26
     /**
26 27
      * The name and signature of the console command.
27 28
      *
@@ -47,7 +48,7 @@  discard block
 block discarded – undo
47 48
     /**
48 49
      * Create a new command instance.
49 50
      */
50
-    public function __construct(){
51
+    public function __construct() {
51 52
         parent::__construct();
52 53
     }
53 54
 
@@ -57,7 +58,7 @@  discard block
 block discarded – undo
57 58
      * @return mixed
58 59
      * @throws \Exception
59 60
      */
60
-    public function handle(){
61
+    public function handle() {
61 62
 
62 63
         // Get start time
63 64
         $start = microtime(true);
@@ -79,7 +80,7 @@  discard block
 block discarded – undo
79 80
             'js'        => '/\$filter\(\'translate\'\)\(\'(?\'identifier\'.*?)\'\)/'
80 81
         ];
81 82
 
82
-        foreach($folders as $folder){
83
+        foreach($folders as $folder) {
83 84
             $aFiles = array_merge($aFiles, File::allFiles(base_path().'/'.$folder));
84 85
         }
85 86
 
@@ -95,13 +96,13 @@  discard block
 block discarded – undo
95 96
 
96 97
             $extension = $file->getExtension();
97 98
 
98
-            if(in_array($extension, $valid_extensions)){
99
+            if(in_array($extension, $valid_extensions)) {
99 100
                 $content = file_get_contents($file);
100 101
 
101 102
                 foreach ($regexes as $key => $regex) {
102 103
                     preg_match_all($regex, $content, $result, PREG_SET_ORDER);
103 104
 
104
-                    if(!empty($result[0])){
105
+                    if(!empty($result[0])) {
105 106
                         $this->addMissing($result, $key);
106 107
                     }
107 108
                 }
@@ -129,7 +130,7 @@  discard block
 block discarded – undo
129 130
     private function addMissing($result, $group) {
130 131
 
131 132
         foreach ($result as $item) {
132
-            try{
133
+            try {
133 134
 
134 135
                 $identifier = trim($item['identifier']);
135 136
                 $this->found_identifier++;
@@ -147,8 +148,7 @@  discard block
 block discarded – undo
147 148
                     $parameter_array = explode(",",$parameter_string);
148 149
 
149 150
                     $parameters = array();
150
-                    foreach($parameter_array as $parameter )
151
-                    {
151
+                    foreach($parameter_array as $parameter ) {
152 152
                         $parameter = explode("=>",$parameter);
153 153
 
154 154
                         $key = str_replace([" ", "'"],"", $parameter[0]);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                     $this->found_parameters++;
161 161
                 }
162 162
 
163
-                if(!isset($aTranslations[$identifier])){
163
+                if(!isset($aTranslations[$identifier])) {
164 164
                     $aTranslations[$identifier] = TranslatorFacade::hasIdentifier($identifier);
165 165
 
166 166
                     if (! $aTranslations[$identifier]) {
@@ -170,12 +170,11 @@  discard block
 block discarded – undo
170 170
                         $this->bar->display();
171 171
                         $this->new_identifier++;
172 172
                     }
173
-                }
174
-                else {
173
+                } else {
175 174
                     $this->dupl_identifier++;
176 175
                 }
177 176
 
178
-            }catch(\Exception $e){
177
+            } catch(\Exception $e) {
179 178
                 $this->bar->clear();
180 179
                 $this->info($identifier.' '.strlen($identifier));
181 180
                 $this->info($e->getMessage());
Please login to merge, or discard this patch.
src/Commands/CacheTranslationCommand.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      *
93 93
      * @return array
94 94
      */
95
-    private function getGroups () {
95
+    private function getGroups() {
96 96
         return DB::table('translation_identifiers')->select('group')->groupBy(['group'])->get()->pluck('group');
97 97
     }
98 98
 
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
      * @param $locale
103 103
      * @return TranslationIdentifier|\Illuminate\Database\Eloquent\Collection|static[]
104 104
      */
105
-    private function loadFromDB ($locale) {
105
+    private function loadFromDB($locale) {
106 106
         // Get all Texts with translations for the given locale
107
-        $trans_identifier =   new TranslationIdentifier();
107
+        $trans_identifier = new TranslationIdentifier();
108 108
 
109
-        $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function ($item) use ($locale) {
109
+        $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function($item) use ($locale) {
110 110
             return $item->where('locale', $locale);
111 111
         })->orWhereHas('translations', null, '<=', 0)
112 112
             ->get();
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
  * Class CacheTranslationCommand
13 13
  * @package Hokan22\LaravelTranslator\commands
14 14
  */
15
-class CacheTranslationCommand extends Command {
15
+class CacheTranslationCommand extends Command
16
+{
16 17
 
17 18
     /**
18 19
      * The name and signature of the console command.
Please login to merge, or discard this patch.
src/migrations/2017_11_27_162357_create_translator_tables.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
         // Create table for storing roles
19 19
         // TODO: Make identifier strings varchar 255
20
-        Schema::create('translation_identifiers', function (Blueprint $table) {
20
+        Schema::create('translation_identifiers', function(Blueprint $table) {
21 21
 
22 22
             $table->increments('id')->unique();
23 23
             $table->text('identifier');
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         });
33 33
 
34 34
         // Create table for storing roles
35
-        Schema::create('translations', function (Blueprint $table) {
35
+        Schema::create('translations', function(Blueprint $table) {
36 36
 
37 37
             $table->integer('translation_identifier_id')->unsigned();
38 38
             $table->foreign('translation_identifier_id')->references('id')->on('translation_identifiers')->onDelete('no action')->onUpdate('no action');
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @return void
13 13
      */
14
-    public function up()
15
-    {
14
+    public function up() {
16 15
         DB::beginTransaction();
17 16
 
18 17
         // Create table for storing roles
@@ -55,8 +54,7 @@  discard block
 block discarded – undo
55 54
      *
56 55
      * @return void
57 56
      */
58
-    public function down()
59
-    {
57
+    public function down() {
60 58
         Schema::drop('translations');
61 59
         Schema::drop('translation_identifiers');
62 60
     }
Please login to merge, or discard this patch.
src/Models/Translations.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
     /**
61 61
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
62 62
      */
63
-    public function translationIdentifier(){
63
+    public function translationIdentifier() {
64 64
         return $this->belongsTo(TranslationIdentifier::class);
65 65
     }
66 66
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,8 @@  discard block
 block discarded – undo
40 40
  * @method static Builder|Translations whereHas($relation, \Closure $callback = null, $operator = '>=', $count = 1)
41 41
  * @method static Builder|Translations where($column, $operator = null, $value = null, $boolean = 'and')
42 42
  */
43
-class Translations extends Model {
43
+class Translations extends Model
44
+{
44 45
 
45 46
 
46 47
     protected $primaryKey = 'this_model_uses_composite_keys';
@@ -60,7 +61,7 @@  discard block
 block discarded – undo
60 61
     /**
61 62
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
62 63
      */
63
-    public function translationIdentifier(){
64
+    public function translationIdentifier() {
64 65
         return $this->belongsTo(TranslationIdentifier::class);
65 66
     }
66 67
 
Please login to merge, or discard this patch.
src/Models/TranslationIdentifier.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
     /**
65 65
      * @return \Illuminate\Database\Eloquent\Relations\HasMany
66 66
      */
67
-    public function translations(){
67
+    public function translations() {
68 68
         return $this->hasMany(Translations::class);
69 69
     }
70 70
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@  discard block
 block discarded – undo
43 43
  * @method static Builder|TranslationIdentifier whereHas($relation, \Closure $callback = null, $operator = '>=', $count = 1)
44 44
  * @method static Builder|TranslationIdentifier where($column, $operator = null, $value = null, $boolean = 'and')
45 45
  */
46
-class TranslationIdentifier extends Model {
46
+class TranslationIdentifier extends Model
47
+{
47 48
 
48 49
     /**
49 50
      * @var array
@@ -64,7 +65,7 @@  discard block
 block discarded – undo
64 65
     /**
65 66
      * @return \Illuminate\Database\Eloquent\Relations\HasMany
66 67
      */
67
-    public function translations(){
68
+    public function translations() {
68 69
         return $this->hasMany(Translations::class);
69 70
     }
70 71
 
Please login to merge, or discard this patch.