Test Setup Failed
Push — a-simpler-manager ( 19ed38...0806fa )
by Ben
07:03
created
src/Managers/Assistants/CrudAssistant.php 2 patches
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,9 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function canCrudAssistant(string $action, $model = null): bool
41 41
     {
42
-        if(!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) return false;
42
+        if(!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) {
43
+            return false;
44
+        }
43 45
 
44 46
         try {
45 47
 
@@ -58,9 +60,13 @@  discard block
 block discarded – undo
58 60
             return false;
59 61
         }
60 62
 
61
-        if(in_array($action, ['index', 'create', 'store'])) return true;
63
+        if(in_array($action, ['index', 'create', 'store'])) {
64
+            return true;
65
+        }
62 66
 
63
-        if(!$model || !$model instanceof StatefulContract) return true;
67
+        if(!$model || !$model instanceof StatefulContract) {
68
+            return true;
69
+        }
64 70
 
65 71
         // Model cannot be in deleted state for editing purposes.
66 72
         if(in_array($action, ['edit', 'update'])) {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
     public function canCrudAssistant(string $action, $model = null): bool
39 39
     {
40
-        if(!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) return false;
40
+        if (!in_array($action, ['index', 'create', 'store', 'edit', 'update', 'delete'])) return false;
41 41
 
42 42
         try {
43 43
 
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
             return false;
57 57
         }
58 58
 
59
-        if(in_array($action, ['index', 'create', 'store'])) return true;
59
+        if (in_array($action, ['index', 'create', 'store'])) return true;
60 60
 
61
-        if(!$model || !$model instanceof StatefulContract) return true;
61
+        if (!$model || !$model instanceof StatefulContract) return true;
62 62
 
63 63
         // Model cannot be in deleted state for editing purposes.
64
-        if(in_array($action, ['edit', 'update'])) {
64
+        if (in_array($action, ['edit', 'update'])) {
65 65
             return !($model->stateOf(PageState::KEY) == PageState::DELETED);
66 66
         }
67 67
 
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
         // Default sorted by publish date
100 100
         $modelClass = $this->managedModelClass();
101 101
         if (Schema::hasColumn((new $modelClass)->getTable(), 'published_at')) {
102
-            $filters = $filters->add(HiddenFilter::make('publish', function ($query) {
102
+            $filters = $filters->add(HiddenFilter::make('publish', function($query) {
103 103
                 return $query->orderBy('published_at', 'DESC');
104 104
             }));
105 105
         }
106 106
 
107 107
         // if model has no timestamps, updated_at doesn't exist
108 108
         if ((new $modelClass)->timestamps) {
109
-            $filters = $filters->add(HiddenFilter::make('updated', function ($query) {
109
+            $filters = $filters->add(HiddenFilter::make('updated', function($query) {
110 110
                 return $query->orderBy('updated_at', 'DESC');
111 111
             }));
112 112
         }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         $model->saveFields($model->fields()->notTagged('edit'), $request->all(), $request->allFiles());
141 141
 
142 142
         return redirect()->to($this->route('edit', $model))
143
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "' . $model->adminLabel('title') . '" is toegevoegd');
143
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "'.$model->adminLabel('title').'" is toegevoegd');
144 144
     }
145 145
 
146 146
     public function edit(Request $request, $id)
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $model->saveFields($model->fields()->notTagged('create'), $request->all(), $request->allFiles());
168 168
 
169 169
         return redirect()->to($this->route('index'))
170
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  <a href="' . $this->route('edit', $model) . '">' . $model->adminLabel('title') . '</a> is aangepast');
170
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  <a href="'.$this->route('edit', $model).'">'.$model->adminLabel('title').'</a> is aangepast');
171 171
     }
172 172
 
173 173
     public function delete(Request $request, $id)
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
         $this->guard('delete', $model);
178 178
 
179 179
         if ($request->get('deleteconfirmation') !== 'DELETE') {
180
-            return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.');
180
+            return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.');
181 181
         }
182 182
 
183 183
         app(DeleteModel::class)->handle($model);
184 184
 
185 185
         return redirect()->to($this->route('index'))
186
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "' . $model->adminLabel('title') . '" is verwijderd.');
186
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "'.$model->adminLabel('title').'" is verwijderd.');
187 187
     }
188 188
 }
Please login to merge, or discard this patch.
src/ManagedModels/Fields/Fields.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function find(string $key): Field
42 42
     {
43
-        if(!isset($this->fields[$key])) {
44
-            throw new \InvalidArgumentException('No field found by key ' . $key);
43
+        if (!isset($this->fields[$key])) {
44
+            throw new \InvalidArgumentException('No field found by key '.$key);
45 45
         }
46 46
 
47 47
         return $this->fields[$key];
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                 continue;
109 109
             }
110 110
 
111
-            $method = 'get' . ucfirst($key);
111
+            $method = 'get'.ucfirst($key);
112 112
 
113 113
             // Reject from list if value does not match expected one
114 114
             if ($value && $value == $field->$method()) {
@@ -124,23 +124,23 @@  discard block
 block discarded – undo
124 124
 
125 125
     public function render(): string
126 126
     {
127
-        return array_reduce($this->fields, function (string $carry, Field $field) {
128
-            return $carry . $field->render();
127
+        return array_reduce($this->fields, function(string $carry, Field $field) {
128
+            return $carry.$field->render();
129 129
         }, '');
130 130
     }
131 131
 
132 132
     public function keyed($key): Fields
133 133
     {
134
-        $keys = (array) $key;
134
+        $keys = (array)$key;
135 135
 
136
-        return new static(array_filter($this->fields, function (Field $field) use ($keys) {
136
+        return new static(array_filter($this->fields, function(Field $field) use ($keys) {
137 137
             return in_array($field->getKey(), $keys);
138 138
         }));
139 139
     }
140 140
 
141 141
     public function tagged($tag): Fields
142 142
     {
143
-        return new static(array_filter($this->fields, function (Field $field) use ($tag) {
143
+        return new static(array_filter($this->fields, function(Field $field) use ($tag) {
144 144
             return $field->tagged($tag);
145 145
         }));
146 146
     }
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
     public function notTagged($tag): Fields
149 149
     {
150 150
         // TODO: to test this...
151
-        return new static(array_filter($this->fields, function (Field $field) use ($tag) {
151
+        return new static(array_filter($this->fields, function(Field $field) use ($tag) {
152 152
             return !$field->tagged($tag);
153 153
         }));
154 154
     }
155 155
 
156 156
     public function untagged(): Fields
157 157
     {
158
-        return new static(array_filter($this->fields, function (Field $field) {
158
+        return new static(array_filter($this->fields, function(Field $field) {
159 159
             return $field->untagged();
160 160
         }));
161 161
     }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     public function offsetGet($offset)
198 198
     {
199 199
         if (!isset($this->fields[$offset])) {
200
-            throw new \RuntimeException('No field found by key [' . $offset . ']');
200
+            throw new \RuntimeException('No field found by key ['.$offset.']');
201 201
         }
202 202
 
203 203
         return $this->fields[$offset];
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     public function offsetSet($offset, $value)
207 207
     {
208 208
         if (!$value instanceof Field) {
209
-            throw new \InvalidArgumentException('Passed value must be of type ' . Field::class);
209
+            throw new \InvalidArgumentException('Passed value must be of type '.Field::class);
210 210
         }
211 211
 
212 212
         $this->fields[$offset] = $value;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
     private function validateFields(array $fields)
238 238
     {
239
-        array_map(function (Field $field) {
239
+        array_map(function(Field $field) {
240 240
         }, $fields);
241 241
     }
242 242
 
Please login to merge, or discard this patch.
src/ManagedModels/Duplication/PageDuplicator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,13 +53,13 @@
 block discarded – undo
53 53
 
54 54
             if ($child instanceof Module && $child->isPageSpecific()) {
55 55
                 $duplicatedChild = $child::create([
56
-                    'slug'           => $targetModel->title ? $targetModel->title . '-' . $child->slug : $child->slug . '-copy',
56
+                    'slug'           => $targetModel->title ? $targetModel->title.'-'.$child->slug : $child->slug.'-copy',
57 57
                     'owner_id'        => $targetModel->id,
58 58
                     'owner_type' => $targetModel->getMorphClass()
59 59
                 ]);
60 60
 
61 61
                 $this->moduleTemplateApplicator->handle($child, $duplicatedChild);
62
-            } else {
62
+            }else {
63 63
                 $duplicatedChild = $child;
64 64
             }
65 65
 
Please login to merge, or discard this patch.
src/ManagedModels/Application/DuplicateContext.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@
 block discarded – undo
22 22
 
23 23
     public function handle($sourceModel, $targetModel): void
24 24
     {
25
-        if(!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) return;
25
+        if (!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) return;
26 26
 
27 27
         $copiedContext = ContextModel::createForOwner($targetModel);
28 28
 
29 29
         /** @var FragmentModel $fragment */
30
-        foreach($context->fragments as $fragment) {
30
+        foreach ($context->fragments as $fragment) {
31 31
             $copiedFragment = $fragment->replicate(['context_id']);
32 32
             $copiedFragment->id = $this->fragmentRepository->nextId();
33 33
             $copiedFragment->context_id = $copiedContext->id;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
 
23 23
     public function handle($sourceModel, $targetModel): void
24 24
     {
25
-        if(!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) return;
25
+        if(!$sourceModel instanceof FragmentsOwner || !$context = ContextModel::ownedBy($sourceModel)) {
26
+            return;
27
+        }
26 28
 
27 29
         $copiedContext = ContextModel::createForOwner($targetModel);
28 30
 
Please login to merge, or discard this patch.
src/Managers/Assistants/FragmentAssistant.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function routeFragmentAssistant(string $action, $model = null, ...$parameters): ?string
33 33
     {
34
-        if(!in_array($action, ['fragment-edit','fragment-update','fragment-delete','fragment-create','fragment-store'])) {
34
+        if (!in_array($action, ['fragment-edit', 'fragment-update', 'fragment-delete', 'fragment-create', 'fragment-store'])) {
35 35
             return null;
36 36
         }
37 37
 
38 38
         $modelKey = $this->managedModelClass()::managedModelKey();
39 39
 
40
-        if(in_array($action, ['fragment-create', 'fragment-store'])) {
40
+        if (in_array($action, ['fragment-create', 'fragment-store'])) {
41 41
             if (!$model || !$model instanceof FragmentsOwner) {
42 42
                 throw new \Exception('Fragment route definition for '.$action.' requires the owning Model as second argument.');
43 43
             }
44 44
 
45
-            return route('chief.' . $modelKey . '.' . $action, array_merge([
45
+            return route('chief.'.$modelKey.'.'.$action, array_merge([
46 46
                 $model::managedModelKey(),
47 47
                 $model->modelReference()->id(),
48 48
             ], $parameters));
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
             throw new \Exception('Fragment route definition for '.$action.' requires the fragment model as second argument.');
53 53
         }
54 54
 
55
-        return route('chief.' . $modelKey . '.' . $action, $model->fragmentModel()->id);
55
+        return route('chief.'.$modelKey.'.'.$action, $model->fragmentModel()->id);
56 56
     }
57 57
 
58 58
     public function canFragmentAssistant(string $action, $model = null): bool
59 59
     {
60
-        return in_array($action, ['fragment-edit','fragment-update','fragment-delete','fragment-create','fragment-store']);
60
+        return in_array($action, ['fragment-edit', 'fragment-update', 'fragment-delete', 'fragment-create', 'fragment-store']);
61 61
     }
62 62
 
63 63
     public function fragmentCreate(Request $request, string $ownerKey, $ownerId)
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
         $model = $this->managedModelClass()::findOrFail($id);
145 145
 
146 146
         if ($request->get('deleteconfirmation') !== 'DELETE') {
147
-            return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.');
147
+            return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.');
148 148
         }
149 149
 
150 150
         app(DeleteModel::class)->handle($model);
151 151
 
152 152
         return redirect()->to($this->route('index'))
153
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "' . $model->adminLabel('title') . '" is verwijderd.');
153
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "'.$model->adminLabel('title').'" is verwijderd.');
154 154
     }
155 155
 
156 156
     private function owner(string $ownerKey, $ownerId): FragmentsOwner
Please login to merge, or discard this patch.
src/Shared/ModelReferences/ModelReference.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
     public static function fromString(string $reference): self
25 25
     {
26 26
         if (false == strpos($reference, '@')) {
27
-            throw new \InvalidArgumentException('Invalid reference composition. A model reference should consist of schema <class>@<id>. [' . $reference . '] was passed instead.');
27
+            throw new \InvalidArgumentException('Invalid reference composition. A model reference should consist of schema <class>@<id>. ['.$reference.'] was passed instead.');
28 28
         }
29 29
 
30 30
         list($className, $id) = explode('@', $reference);
31 31
 
32
-        if("" === $id) {
33
-            throw new \InvalidArgumentException('Missing id on model reference. [' . $reference . '] was passed.');
32
+        if ("" === $id) {
33
+            throw new \InvalidArgumentException('Missing id on model reference. ['.$reference.'] was passed.');
34 34
         }
35 35
 
36
-        return new static($className, (int) $id);
36
+        return new static($className, (int)$id);
37 37
     }
38 38
 
39 39
     /**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $className = $this->className();
47 47
 
48
-        if($this->id == 0) {
48
+        if ($this->id == 0) {
49 49
             return new $className($attributes);
50 50
         }
51 51
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
     public function get(): string
69 69
     {
70
-        return $this->className . '@' . $this->id;
70
+        return $this->className.'@'.$this->id;
71 71
     }
72 72
 
73 73
     public function equals($other): bool
Please login to merge, or discard this patch.
src/Shared/Helpers/Form.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
      */
14 14
     public static function foreachTrans(array $translations, \Closure $callback)
15 15
     {
16
-        foreach($translations as $locale => $trans){
17
-            foreach($trans as $key => $value){
16
+        foreach ($translations as $locale => $trans) {
17
+            foreach ($trans as $key => $value) {
18 18
                 call_user_func($callback, $locale, $key, $value);
19 19
             }
20 20
         }
Please login to merge, or discard this patch.
src/ManagedModels/Application/DeleteModel.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
             // so the user has a small window of recovery
40 40
 
41 41
             if($model instanceof HasAsset) {
42
-                 $this->detachAsset->detachAll($model);
42
+                    $this->detachAsset->detachAll($model);
43 43
             }
44 44
             // TODO: soft-delete the context of this model... (=fragments)
45 45
 //            Relation::deleteRelationsOf($model->getMorphClass(), $model->id);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
             // TODO: schedule for deletion instead of instantly deleting all relations and stuff...
39 39
             // so the user has a small window of recovery
40 40
 
41
-            if($model instanceof HasAsset) {
41
+            if ($model instanceof HasAsset) {
42 42
                  $this->detachAsset->detachAll($model);
43 43
             }
44 44
             // TODO: soft-delete the context of this model... (=fragments)
Please login to merge, or discard this patch.
src/ManagedModels/Assistants/SavingFields.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function saveFields(Fields $fields, array $input, array $files): void
28 28
     {
29
-        foreach($fields as $field){
30
-            if($this->detectCustomSaveMethod($field)) {
29
+        foreach ($fields as $field) {
30
+            if ($this->detectCustomSaveMethod($field)) {
31 31
                 continue;
32 32
             }
33 33
 
34
-            if(!$field->isLocalized())
34
+            if (!$field->isLocalized())
35 35
             {
36 36
                 // Set standard non-localized attribute on the model
37 37
                 ($customSetMethod = $this->detectCustomSetMethod($field))
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
             // Dynamic localized values or standard translated
45 45
             // For standard translations we set value with the colon notation, e.g. title:en
46 46
             Form::foreachTrans(data_get($input, 'trans', []), function($locale, $key, $value) use($field){
47
-                if($key !== $field->getColumn()) return;
47
+                if ($key !== $field->getColumn()) return;
48 48
 
49
-                if($this->isFieldForDynamicValue($field)) {
49
+                if ($this->isFieldForDynamicValue($field)) {
50 50
                     $this->setDynamic($key, $value, $locale);
51
-                } else {
51
+                }else {
52 52
                     $this->{$field->getColumn().':'.$locale} = $value;
53 53
                 }
54 54
             });
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
         $this->save();
58 58
 
59 59
         // Custom save methods
60
-        foreach($fields as $field){
61
-            if($customSaveMethod = $this->detectCustomSaveMethod($field)) {
60
+        foreach ($fields as $field) {
61
+            if ($customSaveMethod = $this->detectCustomSaveMethod($field)) {
62 62
                 $this->$customSaveMethod($field, $input, $files);
63 63
             }
64 64
         }
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 
72 72
     private function detectCustomSaveMethod(Field $field): ?string
73 73
     {
74
-        $saveMethodByKey = 'save' . ucfirst(Str::camel($field->getKey())) . 'Field';
75
-        $saveMethodByType = 'save' . ucfirst(Str::camel($field->getType()->get())) . 'Fields';
74
+        $saveMethodByKey = 'save'.ucfirst(Str::camel($field->getKey())).'Field';
75
+        $saveMethodByType = 'save'.ucfirst(Str::camel($field->getType()->get())).'Fields';
76 76
 
77 77
         foreach ([$saveMethodByKey, $saveMethodByType] as $saveMethod) {
78 78
             if (method_exists($this, $saveMethod)) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
     private function detectCustomSetMethod(Field $field): ?string
87 87
     {
88
-        $methodName = 'set' . ucfirst(Str::camel($field->getKey())) . 'Field';
88
+        $methodName = 'set'.ucfirst(Str::camel($field->getKey())).'Field';
89 89
 
90 90
         return (method_exists($this, $methodName)) ? $methodName : null;
91 91
     }
@@ -107,6 +107,6 @@  discard block
 block discarded – undo
107 107
 
108 108
     private function saveImageFields(ImageField $field, array $input)
109 109
     {
110
-        app(ImageFieldHandler::class)->handle($this, $field, data_get($input, 'images.' . $field->getName(), []), $input);
110
+        app(ImageFieldHandler::class)->handle($this, $field, data_get($input, 'images.'.$field->getName(), []), $input);
111 111
     }
112 112
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,9 @@
 block discarded – undo
44 44
             // Dynamic localized values or standard translated
45 45
             // For standard translations we set value with the colon notation, e.g. title:en
46 46
             Form::foreachTrans(data_get($input, 'trans', []), function($locale, $key, $value) use($field){
47
-                if($key !== $field->getColumn()) return;
47
+                if($key !== $field->getColumn()) {
48
+                    return;
49
+                }
48 50
 
49 51
                 if($this->isFieldForDynamicValue($field)) {
50 52
                     $this->setDynamic($key, $value, $locale);
Please login to merge, or discard this patch.