Passed
Push — ft/urls ( 5c631b...3903c5 )
by Ben
95:30 queued 50:10
created
src/Urls/SaveUrlSlugs.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     private function saveRecord(string $locale, ?string $slug)
40 40
     {
41 41
         // Existing ones for this locale?
42
-        $nonRedirectsWithSameLocale = $this->existingRecords->filter(function ($record) use ($locale) {
42
+        $nonRedirectsWithSameLocale = $this->existingRecords->filter(function($record) use ($locale) {
43 43
             return (
44 44
                 $record->locale == $locale &&
45 45
                 !$record->isRedirect()
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 
56 56
         // If slug entry is left empty, all existing records will be deleted
57 57
         if (!$slug) {
58
-            $nonRedirectsWithSameLocale->each(function ($existingRecord) {
58
+            $nonRedirectsWithSameLocale->each(function($existingRecord) {
59 59
                 $existingRecord->delete();
60 60
             });
61 61
         } elseif ($nonRedirectsWithSameLocale->isEmpty()) {
62 62
             $this->createRecord($locale, $slug);
63
-        } else {
63
+        }else {
64 64
             // Only replace the existing records that differ from the current passed slugs
65
-            $nonRedirectsWithSameLocale->each(function ($existingRecord) use ($slug) {
65
+            $nonRedirectsWithSameLocale->each(function($existingRecord) use ($slug) {
66 66
                 if ($existingRecord->slug != $slug) {
67 67
                     $existingRecord->replaceAndRedirect(['slug' => $slug]);
68 68
                 }
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
      */
88 88
     private function deleteIdenticalRedirects($existingRecords, $locale, $slug): void
89 89
     {
90
-        $existingRecords->filter(function ($record) use ($locale) {
90
+        $existingRecords->filter(function($record) use ($locale) {
91 91
             return (
92 92
                 $record->locale == $locale &&
93 93
                 $record->isRedirect()
94 94
             );
95
-        })->each(function ($existingRecord) use ($slug) {
95
+        })->each(function($existingRecord) use ($slug) {
96 96
             if ($existingRecord->slug == $slug) {
97 97
                 $existingRecord->delete();
98 98
             }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      */
107 107
     private function prependBaseUrlSegment(string $slug, $locale): string
108 108
     {
109
-        $slugWithBaseSegment = $this->model->baseUrlSegment($locale) . '/' . $slug;
109
+        $slugWithBaseSegment = $this->model->baseUrlSegment($locale).'/'.$slug;
110 110
         $slugWithBaseSegment = trim($slugWithBaseSegment, '/');
111 111
 
112 112
         // If slug with base segment is empty string, it means that the passed slug was probably a "/" character.
Please login to merge, or discard this patch.
src/Urls/ChiefResponse.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
                 return static::createRedirect($model->url($locale));
40 40
             }
41 41
 
42
-            if (method_exists($model, 'isPublished') && ! $model->isPublished()) {
42
+            if (method_exists($model, 'isPublished') && !$model->isPublished()) {
43 43
 
44 44
                 /** When admin is logged in and this request is in preview mode, we allow the view */
45
-                if (! PreviewMode::fromRequest()->check()) {
46
-                    throw new NotFoundHttpException('Model found for request ['. $slug .'] but it is not published.');
45
+                if (!PreviewMode::fromRequest()->check()) {
46
+                    throw new NotFoundHttpException('Model found for request ['.$slug.'] but it is not published.');
47 47
                 }
48 48
             }
49 49
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             }
55 55
         }
56 56
 
57
-        throw new NotFoundHttpException('No url or model found for request ['. $slug .'] for locale ['.$locale.'].');
57
+        throw new NotFoundHttpException('No url or model found for request ['.$slug.'] for locale ['.$locale.'].');
58 58
     }
59 59
 
60 60
     private static function createRedirect(string $url)
Please login to merge, or discard this patch.
src/Fields/Types/Field.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Thinktomorrow\Chief\Fields\Types;
6 6
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         }
143 143
 
144 144
         if (!in_array($name, ['label', 'key', 'description', 'column', 'name', 'prepend', 'append'])) {
145
-            throw new \InvalidArgumentException('Cannot set value by ['. $name .'].');
145
+            throw new \InvalidArgumentException('Cannot set value by ['.$name.'].');
146 146
         }
147 147
 
148 148
         $this->values[$name] = $arguments[0];
Please login to merge, or discard this patch.
src/Concerns/Viewable/Viewable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
         // If no view has been created for this model, we try once again to fetch the content value if any. This will silently fail
38 38
         // if no content value is present. We consider the 'content' attribute to be a default for our copy.
39
-        return isset($this->content) ? (string) $this->content : '';
39
+        return isset($this->content) ? (string)$this->content : '';
40 40
     }
41 41
 
42 42
     public function setViewParent(ActsAsParent $parent): ViewableContract
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         }
65 65
 
66 66
         if (config('thinktomorrow.chief.strict')) {
67
-            throw new NotFoundViewKey('Missing view key. Please add a [viewKey] property to ' . get_class($this));
67
+            throw new NotFoundViewKey('Missing view key. Please add a [viewKey] property to '.get_class($this));
68 68
         };
69 69
 
70 70
         return '';
Please login to merge, or discard this patch.
src/Management/Application/StoringAndUpdatingFields.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
             // Media fields are treated separately
28 28
             if ($field->ofType(FieldType::MEDIA, FieldType::DOCUMENT)) {
29
-                if (! isset($this->saveMethods['_files'])) {
29
+                if (!isset($this->saveMethods['_files'])) {
30 30
                     $this->saveMethods['_files'] = ['field' => new Fields([$field]), 'method' => 'uploadMedia'];
31 31
                     continue;
32 32
                 }
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             }
37 37
 
38 38
             // Custom set methods - default is the generic setField() method.
39
-            $methodName = 'set'. ucfirst(camel_case($field->key())) . 'Field';
39
+            $methodName = 'set'.ucfirst(camel_case($field->key())).'Field';
40 40
             (method_exists($manager, $methodName))
41 41
                 ? $manager->$methodName($field, $request)
42 42
                 : $manager->setField($field, $request);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
     protected function detectCustomSaveMethods(Manager $manager, Field $field): bool
50 50
     {
51
-        $saveMethodName = 'save'. ucfirst(camel_case($field->key())) . 'Field';
51
+        $saveMethodName = 'save'.ucfirst(camel_case($field->key())).'Field';
52 52
 
53 53
         // Custom save method on assistant
54 54
         foreach ($manager->assistants() as $assistant) {
Please login to merge, or discard this patch.
src/Management/Assistants/AssistedManager.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public function isAssistedBy(string $assistant): bool
19 19
     {
20
-        return !! $this->getAssistantClass($assistant);
20
+        return !!$this->getAssistantClass($assistant);
21 21
     }
22 22
 
23 23
     public function assistants(): array
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function assistant(string $assistant): Assistant
42 42
     {
43
-        if (! $this->isAssistedBy($assistant)) {
44
-            throw new MissingAssistant('No assistant [' . $assistant . '] present on manager ' . get_class($this));
43
+        if (!$this->isAssistedBy($assistant)) {
44
+            throw new MissingAssistant('No assistant ['.$assistant.'] present on manager '.get_class($this));
45 45
         }
46 46
 
47 47
         $instance = app($this->getAssistantClass($assistant));
Please login to merge, or discard this patch.
src/Management/Assistants/UrlAssistant.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 
24 24
     public function manager(Manager $manager)
25 25
     {
26
-        $this->manager  = $manager;
26
+        $this->manager = $manager;
27 27
 
28
-        if (! $manager->model() instanceof ProvidesUrl) {
29
-            throw new \Exception('UrlAssistant requires the model interfaced by ' . ProvidesUrl::class . '.');
28
+        if (!$manager->model() instanceof ProvidesUrl) {
29
+            throw new \Exception('UrlAssistant requires the model interfaced by '.ProvidesUrl::class.'.');
30 30
         }
31 31
 
32 32
         $this->model = $manager->model();
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
             InputField::make('url-slugs')
55 55
                 ->validation(
56 56
                     [
57
-                        'url-slugs' => ['array', 'min:1', new UniqueUrlSlugRule(($this->model && $this->model->exists) ? $this->model : null),],
57
+                        'url-slugs' => ['array', 'min:1', new UniqueUrlSlugRule(($this->model && $this->model->exists) ? $this->model : null), ],
58 58
                     ],
59 59
                     [],
60 60
                     [
61 61
                         'url-slugs.*' => 'taalspecifieke link',
62 62
                     ])
63 63
                 ->view('chief::back._fields.url-slugs')
64
-                ->viewData(['fields' => UrlSlugFields::fromModel($this->model) ]),
64
+                ->viewData(['fields' => UrlSlugFields::fromModel($this->model)]),
65 65
         ]);
66 66
     }
67 67
 
Please login to merge, or discard this patch.
src/Management/AbstractManager.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
             $this->filters()->apply($builder);
73 73
 
74 74
             $results = $builder->get();
75
-        } else {
75
+        }else {
76 76
             $results = $model::all();
77 77
         }
78 78
 
79
-        return $results->map(function ($model) {
79
+        return $results->map(function($model) {
80 80
             return (new static($this->registration))->manage($model);
81 81
         });
82 82
     }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
     public function guard($verb): Manager
146 146
     {
147
-        if (! $this->can($verb)) {
147
+        if (!$this->can($verb)) {
148 148
             NotAllowedManagerRoute::notAllowedVerb($verb, $this);
149 149
         }
150 150
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $fields = $this->fields();
168 168
 
169 169
         foreach ($this->assistants() as $assistant) {
170
-            if (! method_exists($assistant, 'fields')) {
170
+            if (!method_exists($assistant, 'fields')) {
171 171
                 continue;
172 172
             }
173 173
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
                 // Could be translatable field
208 208
                 if ($this->isTranslatableKey($field)) {
209
-                    $attribute = substr($field, strrpos($field, '.') + 1);
209
+                    $attribute = substr($field, strrpos($field, '.')+1);
210 210
                     $locale = substr($field, strlen('trans.'), 2);
211 211
 
212 212
                     return $this->model->getTranslationFor($attribute, $locale);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
             // Make our media fields able to be translatable as well...
246 246
             if ($field->ofType(FieldType::MEDIA, FieldType::DOCUMENT)) {
247
-                throw new \Exception('Cannot process the ' . $field->key . ' media field. Currently no support for translatable media files. We should fix this!');
247
+                throw new \Exception('Cannot process the '.$field->key.' media field. Currently no support for translatable media files. We should fix this!');
248 248
             }
249 249
 
250 250
             // Okay so this is a bit odd but since all translations are expected to be inside the trans
Please login to merge, or discard this patch.
src/Nav/Nav.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
     public static function fromKeys($keys)
21 21
     {
22
-        $keys = (array) $keys;
22
+        $keys = (array)$keys;
23 23
         $collection = collect();
24 24
 
25 25
         /** @var Managers */
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
     public static function fromTags($tags)
35 35
     {
36
-        $tags = (array) $tags;
36
+        $tags = (array)$tags;
37 37
         $collection = collect();
38 38
 
39 39
         /** @var Managers */
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
     private static function fromManagers(Collection $collection)
54 54
     {
55
-        return new static(...$collection->reject(function ($manager) {
55
+        return new static(...$collection->reject(function($manager) {
56 56
             return !$manager->can('index');
57
-        })->map(function ($manager) {
57
+        })->map(function($manager) {
58 58
             return new NavItem($manager->details()->plural, $manager->route('index'), [
59 59
                 'key' => $manager->details()->key,
60 60
                 'tags' => app(Register::class)->filterByKey($manager->details()->key)->first()->tags()
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
     public function rejectKeys($keys)
66 66
     {
67
-        $keys = (array) $keys;
67
+        $keys = (array)$keys;
68 68
 
69 69
         foreach ($this->items as $k => $item) {
70 70
             if (in_array($item->details('key', ''), $keys)) {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
     public function rejectTags($tags)
79 79
     {
80
-        $tags = (array) $tags;
80
+        $tags = (array)$tags;
81 81
 
82 82
         foreach ($this->items as $k => $item) {
83 83
             if (count(array_intersect($item->details('tags', []), $tags)) > 0) {
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         $output = '';
120 120
 
121 121
         foreach ($this->items as $item) {
122
-            $output .= '<a class="' . (isActiveUrl($item->url()) ? 'active' : '') . '" href="'.$item->url().'">';
122
+            $output .= '<a class="'.(isActiveUrl($item->url()) ? 'active' : '').'" href="'.$item->url().'">';
123 123
             $output .= $title ?? ucfirst($item->title());
124 124
             $output .= '</a>';
125 125
         }
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 
147 147
         $items = '';
148 148
         foreach ($this->items as $item) {
149
-            $items .= '<a class="' . (isActiveUrl($item->url()) ? 'active' : '') . '" href="'.$item->url().'">';
149
+            $items .= '<a class="'.(isActiveUrl($item->url()) ? 'active' : '').'" href="'.$item->url().'">';
150 150
             $items .= $item->title();
151 151
             $items .= '</a>';
152 152
         }
153 153
 
154 154
         // Surround within vue dropdown
155 155
         $output = '<dropdown>';
156
-        $output .= '<span class="center-y nav-item" slot="trigger" slot-scope="{ toggle, isActive }" @click="toggle">'. ($title ?? 'Collecties') .'</span>';
156
+        $output .= '<span class="center-y nav-item" slot="trigger" slot-scope="{ toggle, isActive }" @click="toggle">'.($title ?? 'Collecties').'</span>';
157 157
         $output .= '<div v-cloak class="dropdown-box inset-s">';
158 158
         $output .= $items;
159 159
         $output .= '</div>';
Please login to merge, or discard this patch.