Passed
Pull Request — 2.x (#1042)
by Antonio Carlos
06:10
created
src/Http/Controllers/Admin/IconsController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
     {
21 21
         $icons = collect(
22 22
             config('twill.block_editor.directories.source.icons')
23
-        )->reduce(function (Collection $keep, $path) {
23
+        )->reduce(function(Collection $keep, $path) {
24 24
             if (!$this->files->exists($path)) {
25 25
                 return $keep;
26 26
             }
27 27
 
28
-            $files = collect($this->files->files($path))->map(function (
28
+            $files = collect($this->files->files($path))->map(function(
29 29
                 SplFileInfo $file
30 30
             ) {
31 31
                 if (in_array($file->getFilename(), config('twill.internal_icons'))) {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             abort(404);
55 55
         }
56 56
 
57
-        return response()->stream(function () use ($file) {
57
+        return response()->stream(function() use ($file) {
58 58
             echo $this->files->get($file);
59 59
         }, 200, ["Content-Type" => "image/svg+xml"]);
60 60
 
Please login to merge, or discard this patch.
src/Commands/ListBlocks.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     {
48 48
         $this->blockCollection
49 49
             ->getMissingDirectories()
50
-            ->each(function ($directory) {
50
+            ->each(function($directory) {
51 51
                 $this->error("Directory not found: {$directory}");
52 52
             });
53 53
     }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         return $blockCollection
62 62
             ->first()
63 63
             ->keys()
64
-            ->map(function ($key) {
64
+            ->map(function($key) {
65 65
                 return Str::studly($key);
66 66
             })
67 67
             ->toArray();
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 
82 82
         return $this->blockCollection
83 83
             ->collect()
84
-            ->reject(function (Block $block) use ($sourceFiltered) {
84
+            ->reject(function(Block $block) use ($sourceFiltered) {
85 85
                 return $sourceFiltered && !$this->option($block->source);
86 86
             })
87
-            ->reject(function (Block $block) use ($typeFiltered) {
87
+            ->reject(function(Block $block) use ($typeFiltered) {
88 88
                 return $this->dontPassTextFilter($block) ||
89 89
                     ($typeFiltered &&
90 90
                     !$this->option(Str::plural($block->type)));
91 91
             })
92
-            ->map(function (Block $block) {
92
+            ->map(function(Block $block) {
93 93
                 return $this->colorize(
94 94
                     $this->option('short') ? $block->toShortList() : $block->toList()
95 95
                 );
96 96
             })
97
-            ->sortBy(function ($block) {
97
+            ->sortBy(function($block) {
98 98
                 return [$block['group'], $block['title']];
99 99
             });
100 100
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         if (filled($filter = $this->argument('filter'))) {
153 153
             return !$block
154 154
                 ->toList()
155
-                ->reduce(function ($keep, $element) use ($filter) {
155
+                ->reduce(function($keep, $element) use ($filter) {
156 156
                     return $keep ||
157 157
                     Str::contains(
158 158
                         Str::lower($element),
Please login to merge, or discard this patch.
src/Services/Blocks/BlockMaker.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 
354 354
         return collect(
355 355
             config('twill.block_editor.directories.source.icons')
356
-        )->reduce(function ($keep, $path) use ($icon) {
356
+        )->reduce(function($keep, $path) use ($icon) {
357 357
             if ($keep) {
358 358
                 return $keep;
359 359
             }
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
                 return null;
363 363
             }
364 364
 
365
-            return collect($this->files->files($path))->reduce(function ($keep, SplFileInfo $file) use ($icon) {
365
+            return collect($this->files->files($path))->reduce(function($keep, SplFileInfo $file) use ($icon) {
366 366
                 if ($keep) {
367 367
                     return $keep;
368 368
                 }
Please login to merge, or discard this patch.
src/Repositories/BlockRepository.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
         if (Schema::hasTable(config('twill.related_table', 'twill_related'))) {
47 47
             $relatedItems = Collection::make();
48 48
 
49
-            Collection::make($fields['browsers'])->each(function ($items, $browserName) use (&$relatedItems) {
50
-                Collection::make($items)->each(function ($item) use ($browserName, &$relatedItems) {
49
+            Collection::make($fields['browsers'])->each(function($items, $browserName) use (&$relatedItems) {
50
+                Collection::make($items)->each(function($item) use ($browserName, &$relatedItems) {
51 51
                     try {
52 52
                         $repository = $this->getModelRepository($item['endpointType'] ?? $browserName);
53 53
                         $relatedItems->push((object) [
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     {
76 76
         if (Schema::hasTable(config('twill.related_table', 'twill_related'))) {
77 77
             if (isset($fields['browsers'])) {
78
-                Collection::make($fields['browsers'])->each(function ($items, $browserName) use ($object) {
78
+                Collection::make($fields['browsers'])->each(function($items, $browserName) use ($object) {
79 79
                     $object->saveRelated($items, $browserName);
80 80
                 });
81 81
             }
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
             $blocksList = app(BlockCollection::class)->getBlockList();
108 108
         }
109 109
 
110
-        $block['type'] = $blocksList->keyBy('name')->search(function ($blockConfig) use ($block) {
110
+        $block['type'] = $blocksList->keyBy('name')->search(function($blockConfig) use ($block) {
111 111
             return $blockConfig['component'] === $block['type'];
112 112
         });
113 113
 
114 114
         $block['content'] = empty($block['content']) ? new \stdClass : (object) $block['content'];
115 115
 
116 116
         if ($block['browsers']) {
117
-            $browsers = Collection::make($block['browsers'])->map(function ($items) {
117
+            $browsers = Collection::make($block['browsers'])->map(function($items) {
118 118
                 return Collection::make($items)->pluck('id');
119 119
             })->toArray();
120 120
 
Please login to merge, or discard this patch.
src/Repositories/Behaviors/HandleRepeaters.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $relationRepository = $this->getModelRepository($relation, $model);
64 64
 
65 65
         if (!$keepExisting) {
66
-            $object->$relation()->each(function ($repeaterElement) {
66
+            $object->$relation()->each(function($repeaterElement) {
67 67
                 $repeaterElement->forceDelete();
68 68
             });
69 69
         }
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 
237 237
             if (isset($relatedItemFormFields['medias'])) {
238 238
                 if (config('twill.media_library.translated_form_fields', false)) {
239
-                    Collection::make($relatedItemFormFields['medias'])->each(function ($rolesWithMedias, $locale) use (&$repeatersMedias, $relation, $relationItem) {
240
-                        $repeatersMedias[] = Collection::make($rolesWithMedias)->mapWithKeys(function ($medias, $role) use ($locale, $relation, $relationItem) {
239
+                    Collection::make($relatedItemFormFields['medias'])->each(function($rolesWithMedias, $locale) use (&$repeatersMedias, $relation, $relationItem) {
240
+                        $repeatersMedias[] = Collection::make($rolesWithMedias)->mapWithKeys(function($medias, $role) use ($locale, $relation, $relationItem) {
241 241
                             return [
242 242
                                 "blocks[$relation-$relationItem->id][$role][$locale]" => $medias,
243 243
                             ];
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
             }
252 252
 
253 253
             if (isset($relatedItemFormFields['files'])) {
254
-                Collection::make($relatedItemFormFields['files'])->each(function ($rolesWithFiles, $locale) use (&$repeatersFiles, $relation, $relationItem) {
255
-                    $repeatersFiles[] = Collection::make($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $relation, $relationItem) {
254
+                Collection::make($relatedItemFormFields['files'])->each(function($rolesWithFiles, $locale) use (&$repeatersFiles, $relation, $relationItem) {
255
+                    $repeatersFiles[] = Collection::make($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $relation, $relationItem) {
256 256
                         return [
257 257
                             "blocks[$relation-$relationItem->id][$role][$locale]" => $files,
258 258
                         ];
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
      */
303 303
     protected function getRepeaters()
304 304
     {
305
-        return collect($this->repeaters)->map(function ($repeater, $key) {
305
+        return collect($this->repeaters)->map(function($repeater, $key) {
306 306
             $repeaterName = is_string($repeater) ? $repeater : $key;
307 307
             return [
308 308
                 'relation' => !empty($repeater['relation']) ? $repeater['relation'] : $this->inferRelationFromRepeaterName($repeaterName),
Please login to merge, or discard this patch.
src/Repositories/SettingRepository.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function byKey($key, $section = null)
36 36
     {
37
-        return $this->model->when($section, function ($query) use ($section) {
37
+        return $this->model->when($section, function($query) use ($section) {
38 38
             $query->where('section', $section);
39 39
         })->where('key', $key)->exists() ? $this->model->where('key', $key)->with('translations')->first()->value : null;
40 40
     }
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function getFormFields($section = null)
47 47
     {
48
-        $settings = $this->model->when($section, function ($query) use ($section) {
48
+        $settings = $this->model->when($section, function($query) use ($section) {
49 49
             $query->where('section', $section);
50 50
         })->with('translations', 'medias')->get();
51 51
 
52 52
 
53 53
         if (config('twill.media_library.translated_form_fields', false)) {
54
-            $medias = $settings->reduce(function ($carry, $setting) {
54
+            $medias = $settings->reduce(function($carry, $setting) {
55 55
                 foreach (getLocales() as $locale) {
56 56
                     if (!empty(parent::getFormFields($setting)['medias'][$locale]) && !empty(parent::getFormFields($setting)['medias'][$locale][$setting->key]))
57 57
                     {
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
                 return $carry;
62 62
             });
63 63
         } else {
64
-            $medias = $settings->mapWithKeys(function ($setting) {
64
+            $medias = $settings->mapWithKeys(function($setting) {
65 65
                 return [$setting->key => parent::getFormFields($setting)['medias'][$setting->key] ?? null];
66 66
             })->filter()->toArray();
67 67
         }
68 68
 
69
-        return $settings->mapWithKeys(function ($setting) {
69
+        return $settings->mapWithKeys(function($setting) {
70 70
             $settingValue = [];
71 71
 
72 72
             foreach ($setting->translations as $translation) {
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
 
118 118
             if (config('twill.media_library.translated_form_fields', false)) {
119 119
                 foreach (getLocales() as $locale) {
120
-                    $medias["{$role}[{$locale}]"] = Collection::make($settingsFields['medias'][$role][$locale])->map(function ($media) {
120
+                    $medias["{$role}[{$locale}]"] = Collection::make($settingsFields['medias'][$role][$locale])->map(function($media) {
121 121
                         return json_decode($media, true);
122 122
                     })->filter()->toArray();
123 123
                 }
124 124
             } else {
125
-                $medias =  [
126
-                    $role => Collection::make($settingsFields['medias'][$role])->map(function ($media) {
125
+                $medias = [
126
+                    $role => Collection::make($settingsFields['medias'][$role])->map(function($media) {
127 127
                         return json_decode($media, true);
128 128
                     })->values()->filter()->toArray(),
129 129
                 ];
Please login to merge, or discard this patch.
src/Models/Media.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
 
24 24
     public function __construct(array $attributes = [])
25 25
     {
26
-        $this->fillable(array_merge($this->fillable, Collection::make(config('twill.media_library.extra_metadatas_fields'))->map(function ($field) {
26
+        $this->fillable(array_merge($this->fillable, Collection::make(config('twill.media_library.extra_metadatas_fields'))->map(function($field) {
27 27
             return $field['name'];
28 28
         })->toArray()));
29 29
 
30
-        Collection::make(config('twill.media_library.translatable_metadatas_fields'))->each(function ($field) {
30
+        Collection::make(config('twill.media_library.translatable_metadatas_fields'))->each(function($field) {
31 31
             $this->casts[$field] = 'json';
32 32
         });
33 33
 
34 34
         parent::__construct($attributes);
35 35
     }
36 36
 
37
-    public function scopeUnused ($query)
37
+    public function scopeUnused($query)
38 38
     {
39 39
         $usedIds = DB::table(config('twill.mediables_table'))->get()->pluck('media_id');
40 40
         return $query->whereNotIn('id', $usedIds->toArray())->get();
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             'medium' => ImageService::getUrl($this->uuid, ["h" => "430"]),
76 76
             'width' => $this->width,
77 77
             'height' => $this->height,
78
-            'tags' => $this->tags->map(function ($tag) {
78
+            'tags' => $this->tags->map(function($tag) {
79 79
                 return $tag->name;
80 80
             }),
81 81
             'deleteUrl' => $this->canDeleteSafely() ? moduleRoute('medias', 'media-library', 'destroy', $this->id) : null,
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                     'caption' => $this->caption,
88 88
                     'altText' => $this->alt_text,
89 89
                     'video' => null,
90
-                ] + Collection::make(config('twill.media_library.extra_metadatas_fields'))->mapWithKeys(function ($field) {
90
+                ] + Collection::make(config('twill.media_library.extra_metadatas_fields'))->mapWithKeys(function($field) {
91 91
                     return [
92 92
                         $field['name'] => $this->{$field['name']},
93 93
                     ];
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
         if ($this->update($fields) && $this->isReferenced())
144 144
         {
145
-            DB::table(config('twill.mediables_table', 'twill_mediables'))->where('media_id', $this->id)->get()->each(function ($mediable) use ($prevWidth, $prevHeight) {
145
+            DB::table(config('twill.mediables_table', 'twill_mediables'))->where('media_id', $this->id)->get()->each(function($mediable) use ($prevWidth, $prevHeight) {
146 146
                 
147 147
                 if ($prevWidth != $this->width) {
148 148
                     $mediable->crop_x = 0;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                     $mediable->crop_h = $this->height;
155 155
                 }
156 156
 
157
-                DB::table(config('twill.mediables_table', 'twill_mediables'))->where('id', $mediable->id)->update((array)$mediable);
157
+                DB::table(config('twill.mediables_table', 'twill_mediables'))->where('id', $mediable->id)->update((array) $mediable);
158 158
             });
159 159
         }
160 160
     }
Please login to merge, or discard this patch.
src/Helpers/helpers.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 if (!function_exists('dumpUsableSqlQuery')) {
10 10
     function dumpUsableSqlQuery($query)
11 11
     {
12
-        dd(vsprintf(str_replace('?', '%s', $query->toSql()), array_map(function ($binding) {
12
+        dd(vsprintf(str_replace('?', '%s', $query->toSql()), array_map(function($binding) {
13 13
             return is_numeric($binding) ? $binding : "'{$binding}'";
14 14
         }, $query->getBindings())));
15 15
     }
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
     {
202 202
         $blockList = app(BlockCollection::class)->getBlockList();
203 203
 
204
-        $appBlocksList = $blockList->filter(function ($block) {
204
+        $appBlocksList = $blockList->filter(function($block) {
205 205
             return $block['source'] !== A17\Twill\Services\Blocks\Block::SOURCE_TWILL;
206 206
         });
207 207
 
208 208
         $finalBlockList = $blockList->filter(
209
-            function ($block) use ($blocks, $groups, $appBlocksList) {
209
+            function($block) use ($blocks, $groups, $appBlocksList) {
210 210
                 if ($block['group'] === A17\Twill\Services\Blocks\Block::SOURCE_TWILL) {
211 211
                     if (!collect(
212 212
                         config('twill.block_editor.use_twill_blocks')
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                     }
216 216
 
217 217
                     if (count($appBlocksList) > 0 && $appBlocksList->contains(
218
-                        function ($appBlock) use ($block) {
218
+                        function($appBlock) use ($block) {
219 219
                             return $appBlock['name'] === $block['name'];
220 220
                         })
221 221
                     ) {
Please login to merge, or discard this patch.
src/Commands/ModuleMakeDeprecated.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
 
44 44
         $this->call('twill:make:module', [
45 45
             'moduleName' => $this->argument('moduleName'),
46
-        ] + $options->mapWithKeys(function ($value, $key) {
46
+        ] + $options->mapWithKeys(function($value, $key) {
47 47
             return ["--{$key}" => $value];
48 48
         })->toArray());
49 49
     }
Please login to merge, or discard this patch.