Passed
Pull Request — 2.x (#1421)
by Quentin
09:12
created
src/Http/Controllers/Admin/FeaturedController.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
         $featuredSources = $this->getFeaturedSources($request, $featuredSection, $filters['search'] ?? '');
44 44
 
45
-        $contentTypes = Collection::make($featuredSources)->map(function ($source, $sourceKey) {
45
+        $contentTypes = Collection::make($featuredSources)->map(function($source, $sourceKey) {
46 46
             return [
47 47
                 'label' => $source['name'],
48 48
                 'value' => $sourceKey,
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
             return [
56 56
                 'source' => [
57
-                    'content_type' => Arr::first($contentTypes, function ($contentTypeItem) use ($request) {
57
+                    'content_type' => Arr::first($contentTypes, function($contentTypeItem) use ($request) {
58 58
                         return $contentTypeItem['value'] == $request->get('content_type');
59 59
                     }),
60 60
                     'items' => $source['items'],
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     private function getFeaturedItemsByBucket($featuredSection, $featuredSectionKey)
101 101
     {
102 102
         $bucketRouteConfig = $this->config->get('twill.bucketsRoutes') ?? [$featuredSectionKey => 'featured'];
103
-        return Collection::make($featuredSection['buckets'])->map(function ($bucket, $bucketKey) use ($featuredSectionKey, $bucketRouteConfig) {
103
+        return Collection::make($featuredSection['buckets'])->map(function($bucket, $bucketKey) use ($featuredSectionKey, $bucketRouteConfig) {
104 104
             $routePrefix = $bucketRouteConfig[$featuredSectionKey];
105 105
             return [
106 106
                 'id' => $bucketKey,
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                 'acceptedSources' => Collection::make($bucket['bucketables'])->pluck('module'),
110 110
                 'withToggleFeatured' => $bucket['with_starred_items'] ?? false,
111 111
                 'toggleFeaturedLabels' => $bucket['starred_items_labels'] ?? [],
112
-                'children' => Feature::where('bucket_key', $bucketKey)->with('featured')->get()->map(function ($feature) use ($bucket) {
112
+                'children' => Feature::where('bucket_key', $bucketKey)->with('featured')->get()->map(function($feature) use ($bucket) {
113 113
                     if (($item = $feature->featured) != null) {
114 114
                         $forModuleRepository = collect($bucket['bucketables'])->where('module', $feature->featured_type)->first()['repository'] ?? null;
115 115
                         $repository = $this->getRepository($feature->featured_type, $forModuleRepository);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                             'thumbnail' => $item->defaultCmsImage(['w' => 100, 'h' => 100]),
129 129
                         ] : []);
130 130
                     }
131
-                })->reject(function ($item) {
131
+                })->reject(function($item) {
132 132
                     return is_null($item);
133 133
                 })->values()->toArray(),
134 134
             ];
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
         $fetchedModules = [];
147 147
         $featuredSources = [];
148 148
 
149
-        Collection::make($featuredSection['buckets'])->map(function ($bucket, $bucketKey) use (&$fetchedModules, $search, $request) {
150
-            return Collection::make($bucket['bucketables'])->mapWithKeys(function ($bucketable) use (&$fetchedModules, $search, $request) {
149
+        Collection::make($featuredSection['buckets'])->map(function($bucket, $bucketKey) use (&$fetchedModules, $search, $request) {
150
+            return Collection::make($bucket['bucketables'])->mapWithKeys(function($bucketable) use (&$fetchedModules, $search, $request) {
151 151
 
152 152
                 $module = $bucketable['module'];
153 153
                 $repository = $this->getRepository($module, $bucketable['repository'] ?? null);
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
                     'withImage' => $withImage,
177 177
                 ]];
178 178
             });
179
-        })->each(function ($bucketables, $bucket) use (&$featuredSources) {
180
-            $bucketables->each(function ($bucketableData, $bucketable) use (&$featuredSources) {
179
+        })->each(function($bucketables, $bucket) use (&$featuredSources) {
180
+            $bucketables->each(function($bucketableData, $bucketable) use (&$featuredSources) {
181 181
                 $featuredSources[$bucketable]['name'] = $bucketableData['name'];
182 182
                 $featuredSources[$bucketable]['maxPage'] = $bucketableData['items']->lastPage();
183 183
                 $featuredSources[$bucketable]['offset'] = $bucketableData['items']->perPage();
184
-                $featuredSources[$bucketable]['items'] = $bucketableData['items']->map(function ($item) use ($bucketableData, $bucketable) {
184
+                $featuredSources[$bucketable]['items'] = $bucketableData['items']->map(function($item) use ($bucketableData, $bucketable) {
185 185
                     return [
186 186
                         'id' => $item->id,
187 187
                         'name' => $item->titleInBucket ?? $item->title,
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
      */
211 211
     public function save(Request $request, DB $db)
212 212
     {
213
-        $db->transaction(function () use ($request) {
214
-            Collection::make($request->get('buckets'))->each(function ($bucketables, $bucketKey) {
213
+        $db->transaction(function() use ($request) {
214
+            Collection::make($request->get('buckets'))->each(function($bucketables, $bucketKey) {
215 215
                 Feature::where('bucket_key', $bucketKey)->delete();
216 216
                 foreach (($bucketables ?? []) as $position => $bucketable) {
217 217
                     Feature::create([
Please login to merge, or discard this patch.
src/ValidationServiceProvider.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@
 block discarded – undo
16 16
      */
17 17
     public function boot()
18 18
     {
19
-        Validator::extend('absolute_or_relative_url', function ($attribute, $value, $parameters, $validator) {
19
+        Validator::extend('absolute_or_relative_url', function($attribute, $value, $parameters, $validator) {
20 20
             return Str::startsWith($value, '/') || Validator::make([$attribute => $value], [$attribute => 'url'])->passes();
21 21
         }, 'The :attribute should be a valid url (absolute or relative)');
22 22
 
23
-        Validator::extend('relative_or_secure_url', function ($attribute, $value, $parameters) {
23
+        Validator::extend('relative_or_secure_url', function($attribute, $value, $parameters) {
24 24
             return Str::startsWith($value, '/') || filter_var($value, FILTER_VALIDATE_URL) !== false && Str::startsWith($value, 'https');
25 25
         }, 'The :attribute should be a valid url (relative or https)');
26 26
 
27
-        Validator::extend('web_color', function ($attribute, $value, $parameters, $validator) {
27
+        Validator::extend('web_color', function($attribute, $value, $parameters, $validator) {
28 28
             return preg_match('/^([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i', $value);
29 29
         });
30 30
 
31
-        Validator::extend('phone_number', function ($attribute, $value, $parameters) {
31
+        Validator::extend('phone_number', function($attribute, $value, $parameters) {
32 32
             return preg_match("/^[+]?[0-9\-\ ]*$/", $value);
33 33
         });
34 34
 
35
-        Validator::extend('validBlocks', function ($attribute, $value, $parameters, $validator) {
35
+        Validator::extend('validBlocks', function($attribute, $value, $parameters, $validator) {
36 36
             $blockMessages = [];
37 37
 
38 38
             foreach ($value as $block) {
Please login to merge, or discard this patch.
src/Commands/ListIcons.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
     {
66 66
         return collect(
67 67
             config('twill.block_editor.directories.source.icons')
68
-        )->reduce(function (Collection $keep, $path) {
68
+        )->reduce(function(Collection $keep, $path) {
69 69
             if (!$this->files->exists($path)) {
70 70
                 $this->displayError("Directory not found: {$path}");
71 71
 
72 72
                 return $keep;
73 73
             }
74 74
 
75
-            $files = collect($this->files->files($path))->map(function (
75
+            $files = collect($this->files->files($path))->map(function(
76 76
                 SplFileInfo $file
77 77
             ) {
78 78
                 return [
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function handle()
94 94
     {
95
-        $icons = $this->getIconList()->filter(function ($icon) {
95
+        $icons = $this->getIconList()->filter(function($icon) {
96 96
             return $this->isAllowed($icon);
97 97
         });
98 98
 
Please login to merge, or discard this patch.
src/Models/File.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         return DB::table(config('twill.fileables_table', 'twill_fileables'))->where('file_id', $this->id)->count() === 0;
26 26
     }
27 27
 
28
-    public function scopeUnused ($query)
28
+    public function scopeUnused($query)
29 29
     {
30 30
         $usedIds = DB::table(config('twill.fileables_table'))->get()->pluck('file_id');
31 31
         return $query->whereNotIn('id', $usedIds->toArray())->get();
Please login to merge, or discard this patch.
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/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/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/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/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.