Test Setup Failed
Push — a-simpler-manager ( c2997f...b87bbb )
by Ben
06:08
created
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.
src/Site/Menu/ChiefMenu.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     public function sanitize(NodeCollection $collection): NodeCollection
51 51
     {
52 52
         if (!$this->includeHidden) {
53
-            $collection = $collection->shake(function ($node) {
53
+            $collection = $collection->shake(function($node) {
54 54
                 return !$node->hidden_in_menu && !$node->draft;
55 55
             });
56 56
         }
Please login to merge, or discard this patch.
src/Site/Menu/Tree/PrepareMenuItemsForAdminSelect.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,22 +14,22 @@
 block discarded – undo
14 14
         $this->collection = $items;
15 15
 
16 16
         if ($model) {
17
-            $this->collection = $this->collection->prune(function ($node) use ($model) {
17
+            $this->collection = $this->collection->prune(function($node) use ($model) {
18 18
                 return !in_array($model->id, $node->pluckAncestors('id'));
19 19
             });
20 20
         }
21 21
 
22
-        $menu = $this->collection->mapRecursive(function ($node) {
22
+        $menu = $this->collection->mapRecursive(function($node) {
23 23
             $entry = $node->entry();
24 24
             $label = $entry->label;
25
-            $entry->label = $node->depth() != 0 ? (str_repeat('-', $node->depth())) . '>' : '';
25
+            $entry->label = $node->depth() != 0 ? (str_repeat('-', $node->depth())).'>' : '';
26 26
             $entry->label .= $label;
27 27
 
28 28
             return $node->replaceEntry($entry);
29 29
         });
30 30
 
31 31
         $menuitems = collect();
32
-        $menu->flatten()->each(function ($node) use ($menuitems) {
32
+        $menu->flatten()->each(function($node) use ($menuitems) {
33 33
             $menuitems[] = [
34 34
                 'label' => $node->label,
35 35
                 'id'    => $node->id,
Please login to merge, or discard this patch.
src/Site/Menu/Tree/BuildMenuItemsTree.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
             if ($item->ofType(MenuItem::TYPE_INTERNAL) && $owner = $item->owner) {
28 28
                 if (public_method_exists($owner, 'isArchived') && $owner->isArchived()) {
29 29
                     unset($items[$k]);
30
-                } else {
30
+                }else {
31 31
                     $item->url = $item->url();
32 32
 
33 33
                     // Extra info on admin page.
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $collection = NodeCollection::fromArray($items);
51 51
 
52
-        $collection->mapRecursive(function ($node) {
52
+        $collection->mapRecursive(function($node) {
53 53
             return $node->replaceEntry((new MenuItem())->entry($node));
54 54
         });
55 55
 
Please login to merge, or discard this patch.