Test Setup Failed
Push — a-simpler-manager ( e09f23...bb5122 )
by Ben
05:27
created
src/Managers/Register/Registry.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
     public function modelClass(string $key): string
24 24
     {
25
-        if(!isset($this->models[$key])) {
25
+        if (!isset($this->models[$key])) {
26 26
             throw new MissingModelRegistration('No model class registered for key ['.$key.']');
27 27
         }
28 28
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
     public function manager(string $key): Manager
33 33
     {
34
-        if(!isset($this->managers[$key])) {
34
+        if (!isset($this->managers[$key])) {
35 35
             throw new MissingManagerRegistration('No manager registered for key ['.$key.']');
36 36
         }
37 37
 
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
     public function managersWithTags(): array
52 52
     {
53
-        return collect($this->tags->get())->reject(function($tags, $key){
53
+        return collect($this->tags->get())->reject(function($tags, $key) {
54 54
             return !isset($this->managers[$key]);
55
-        })->map(function($tags, $key){
55
+        })->map(function($tags, $key) {
56 56
             return (object)[
57 57
                 'manager' => $this->manager($key),
58 58
                 'tags' => $tags,
Please login to merge, or discard this patch.
src/Managers/Register/TaggedKeys.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function tagged($tags): self
23 23
     {
24
-        $tags = (array) $tags;
24
+        $tags = (array)$tags;
25 25
 
26 26
         return $this->filter(function($value, $key) use($tags){
27 27
             return count(array_intersect($value, $tags)) > 0;
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function notTagged($tags): self
32 32
     {
33
-        $tags = (array) $tags;
33
+        $tags = (array)$tags;
34 34
 
35 35
         return $this->filter(function($value, $key) use($tags){
36 36
             return count(array_intersect($value, $tags)) === 0;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function untagged(): self
41 41
     {
42
-        return $this->filter(function($value){
42
+        return $this->filter(function($value) {
43 43
             return empty($value);
44 44
         });
45 45
     }
Please login to merge, or discard this patch.
src/Managers/Register/Register.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
     {
46 46
         // Check if model class points to ManagedModel interface
47 47
         $ref = new \ReflectionClass($modelClass);
48
-        if(!$ref->implementsInterface(ManagedModel::class)) {
49
-            throw new \DomainException('Class ' . $modelClass . ' should implement contract ' . ManagedModel::class);
48
+        if (!$ref->implementsInterface(ManagedModel::class)) {
49
+            throw new \DomainException('Class '.$modelClass.' should implement contract '.ManagedModel::class);
50 50
         }
51 51
 
52 52
         $managedModelKey = $modelClass::managedModelKey();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $this->container->make(Registry::class)
56 56
             ->registerModel($managedModelKey, $modelClass)
57 57
             ->registerManager($managedModelKey, $manager)
58
-            ->registerTags($managedModelKey, (array) $tags);
58
+            ->registerTags($managedModelKey, (array)$tags);
59 59
 
60 60
         // Register routes
61 61
         $this->container->make(RegisterManagedRoutes::class)(
Please login to merge, or discard this patch.
src/Managers/Exceptions/NotAllowedManagerAction.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@
 block discarded – undo
40 40
 
41 41
     public static function notAllowedAction($action, string $managerKey)
42 42
     {
43
-        return new self('Not allowed to ' . $action . ' a model. ' . ucfirst($action) . ' route is not allowed by the ' . $managerKey . ' manager.');
43
+        return new self('Not allowed to '.$action.' a model. '.ucfirst($action).' route is not allowed by the '.$managerKey.' manager.');
44 44
     }
45 45
 
46 46
     public static function notAllowedPermission($permission, string $managerKey)
47 47
     {
48
-        return new self('Not allowed permission for ' . $permission . ' on a model as managed by the ' . $managerKey . ' manager.');
48
+        return new self('Not allowed permission for '.$permission.' on a model as managed by the '.$managerKey.' manager.');
49 49
     }
50 50
 }
Please login to merge, or discard this patch.
src/Managers/Assistants/FragmentsAssistant.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function routeFragmentsAssistant(string $action, $model = null, ...$parameters): ?string
27 27
     {
28
-        if(!in_array($action, ['fragments-index','fragments-reorder'])) return null;
28
+        if (!in_array($action, ['fragments-index', 'fragments-reorder'])) return null;
29 29
 
30 30
         return $this->generateRoute($action, $model, ...$parameters);
31 31
     }
32 32
 
33 33
     public function canFragmentsAssistant(string $action, $model = null): bool
34 34
     {
35
-        return in_array($action, ['fragments-index','fragments-reorder']);
35
+        return in_array($action, ['fragments-index', 'fragments-reorder']);
36 36
     }
37 37
 
38 38
     public function fragmentsIndex(Request $request, $id)
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $model = $modelClass::findOrFail($id);
44 44
 
45 45
         // Current fragments
46
-        $fragments = app(FragmentRepository::class)->getByOwner($model)->map(function(Fragmentable $model){
46
+        $fragments = app(FragmentRepository::class)->getByOwner($model)->map(function(Fragmentable $model) {
47 47
             return [
48 48
                 'model'    => $model,
49 49
                 'manager'  => app(Registry::class)->manager($model::managedModelKey()),
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         });
52 52
 
53 53
         // Available fragments
54
-        $allowedFragments = array_map(function($fragmentableClass){
54
+        $allowedFragments = array_map(function($fragmentableClass) {
55 55
             $modelClass = app(Registry::class)->modelClass($fragmentableClass::managedModelKey());
56 56
             return [
57 57
                 'manager' => app(Registry::class)->manager($fragmentableClass::managedModelKey()),
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@
 block discarded – undo
25 25
 
26 26
     public function routeFragmentsAssistant(string $action, $model = null, ...$parameters): ?string
27 27
     {
28
-        if(!in_array($action, ['fragments-index','fragments-reorder'])) return null;
28
+        if(!in_array($action, ['fragments-index','fragments-reorder'])) {
29
+            return null;
30
+        }
29 31
 
30 32
         return $this->generateRoute($action, $model, ...$parameters);
31 33
     }
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
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
 
33 33
     public function routeFragmentAssistant(string $action, $model = null, ...$parameters): ?string
34 34
     {
35
-        if(!in_array($action, ['fragment-edit','fragment-update','fragment-delete','fragment-create','fragment-store'])) {
35
+        if (!in_array($action, ['fragment-edit', 'fragment-update', 'fragment-delete', 'fragment-create', 'fragment-store'])) {
36 36
             return null;
37 37
         };
38 38
 
39 39
         $modelKey = $this->managedModelClass()::managedModelKey();
40 40
 
41
-        if(in_array($action, ['fragment-create', 'fragment-store'])) {
41
+        if (in_array($action, ['fragment-create', 'fragment-store'])) {
42 42
             if (!$model || !$model instanceof FragmentsOwner) {
43 43
                 throw new \Exception('Fragment route definition for '.$action.' requires the owning Model as second argument.');
44 44
             }
45 45
 
46
-            return route('chief.' . $modelKey . '.' . $action, array_merge([
46
+            return route('chief.'.$modelKey.'.'.$action, array_merge([
47 47
                 $model::managedModelKey(),
48 48
                 $model->modelReference()->id(),
49 49
             ], $parameters));
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
             throw new \Exception('Fragment route definition for '.$action.' requires the fragment model as second argument.');
54 54
         }
55 55
 
56
-        return route('chief.' . $modelKey . '.' . $action, $model->fragmentModel()->id);
56
+        return route('chief.'.$modelKey.'.'.$action, $model->fragmentModel()->id);
57 57
     }
58 58
 
59 59
     public function canFragmentAssistant(string $action, $model = null): bool
60 60
     {
61
-        return in_array($action, ['fragment-edit','fragment-update','fragment-delete','fragment-create','fragment-store']);
61
+        return in_array($action, ['fragment-edit', 'fragment-update', 'fragment-delete', 'fragment-create', 'fragment-store']);
62 62
     }
63 63
 
64 64
     public function fragmentCreate(Request $request, string $ownerKey, $ownerId)
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
         $model = $this->managedModelClass()::findOrFail($id);
146 146
 
147 147
         if ($request->get('deleteconfirmation') !== 'DELETE') {
148
-            return redirect()->back()->with('messages.warning', $model->adminLabel('title') . ' is niet verwijderd.');
148
+            return redirect()->back()->with('messages.warning', $model->adminLabel('title').' is niet verwijderd.');
149 149
         }
150 150
 
151 151
         app(DeleteManagedModel::class)->handle($model);
152 152
 
153 153
         return redirect()->to($this->route('index'))
154
-            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "' . $model->adminLabel('title') . '" is verwijderd.');
154
+            ->with('messages.success', '<i class="fa fa-fw fa-check-circle"></i>  "'.$model->adminLabel('title').'" is verwijderd.');
155 155
     }
156 156
 
157 157
     private function owner(string $ownerKey, $ownerId): FragmentsOwner
Please login to merge, or discard this patch.
src/Legacy/Fragments/Fragment.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     public static function fromModel(FragmentModel $fragmentModel): self
36 36
     {
37
-        return new static($fragmentModel->key, $fragmentModel->values->all(), new Fields(), (int) $fragmentModel->id);
37
+        return new static($fragmentModel->key, $fragmentModel->values->all(), new Fields(), (int)$fragmentModel->id);
38 38
     }
39 39
 
40 40
     public static function fromNew(string $key, array $values): self
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $modelId = $payload['modelId'];
57 57
         unset($payload['modelId']);
58 58
 
59
-        return new static($key, $payload, new Fields(), (int) $modelId);
59
+        return new static($key, $payload, new Fields(), (int)$modelId);
60 60
     }
61 61
 
62 62
     public function setFields(Fields $fields): self
Please login to merge, or discard this patch.
src/Legacy/Fragments/ManagesFragments.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@
 block discarded – undo
13 13
     public function saveFragmentFields(FragmentField $fragmentField, Request $request)
14 14
     {
15 15
         $payload = $request->input($fragmentField->getDottedName(), []);
16
-        $imagePayload = $request->input('images.' . $fragmentField->getDottedName(), []);
16
+        $imagePayload = $request->input('images.'.$fragmentField->getDottedName(), []);
17 17
 
18 18
         // Compose Fragment instances for each payload entry
19
-        $fragments = array_map(function ($fragmentPayload) use ($fragmentField) {
19
+        $fragments = array_map(function($fragmentPayload) use ($fragmentField) {
20 20
             return Fragment::fromRequestPayload($fragmentField->getKey(), $fragmentPayload); // (new Fragment($field->getKey(), $fragmentPayload));
21 21
         }, $payload);
22 22
 
23 23
         // remove all dead fragments
24
-        $this->existingModel()->removeAllFragments($fragmentField->getKey(), array_map(function (Fragment $fragment) {
24
+        $this->existingModel()->removeAllFragments($fragmentField->getKey(), array_map(function(Fragment $fragment) {
25 25
             return $fragment->hasModelId() ? $fragment->getModelId() : null;
26 26
         }, $fragments));
27 27
 
Please login to merge, or discard this patch.
src/Legacy/Fragments/FragmentField.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -63,22 +63,22 @@
 block discarded – undo
63 63
                 ->setModelIdInputName($this->name . '[' . $k . '][modelId]')
64 64
                 ->setFields($this->fields->clone()->map(function (Field $field) use ($k, $fragment) {
65 65
                     return $field->name($this->name . '.' . $k . '.' . $field->getName())
66
-                                 ->localizedFormat(':name.:locale')
67
-                                 ->valueResolver(function ($model = null, $locale = null, $field) use ($fragment) {
68
-                                     if (isset($field->value)) {
69
-                                         return $field->value;
70
-                                     }
71
-
72
-                                     if ($field instanceof MediaField) {
73
-                                         if (!$fragment->hasModelId()) {
74
-                                             return [];
75
-                                         }
76
-
77
-                                         return $field->getMedia(FragmentModel::find($fragment->getModelId()), $locale);
78
-                                     }
79
-
80
-                                     return $fragment->getValue($field->getColumn(), $locale);
81
-                                 });
66
+                                    ->localizedFormat(':name.:locale')
67
+                                    ->valueResolver(function ($model = null, $locale = null, $field) use ($fragment) {
68
+                                        if (isset($field->value)) {
69
+                                            return $field->value;
70
+                                        }
71
+
72
+                                        if ($field instanceof MediaField) {
73
+                                            if (!$fragment->hasModelId()) {
74
+                                                return [];
75
+                                            }
76
+
77
+                                            return $field->getMedia(FragmentModel::find($fragment->getModelId()), $locale);
78
+                                        }
79
+
80
+                                        return $fragment->getValue($field->getColumn(), $locale);
81
+                                    });
82 82
                 }));
83 83
         }
84 84
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
         // Model is auto-injected by Manager::editFields() method.
49 49
         if (($this->model)) {
50 50
             if (!method_exists($this->model, 'getFragments')) {
51
-                throw new \RuntimeException(get_class($this->model) . ' is missing the ' . HasFragments::class . ' trait.');
51
+                throw new \RuntimeException(get_class($this->model).' is missing the '.HasFragments::class.' trait.');
52 52
             }
53 53
 
54 54
             if (count($modelFragments = $this->model->getFragments($this->getKey())) > 0) {
55
-                $fragments = $modelFragments->map(function (FragmentModel $fragmentModel) {
55
+                $fragments = $modelFragments->map(function(FragmentModel $fragmentModel) {
56 56
                     return Fragment::fromModel($fragmentModel);
57 57
                 })->all();
58 58
             }
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 
61 61
         foreach ($fragments as $k => $fragment) {
62 62
             $fragments[$k] = $fragments[$k]
63
-                ->setModelIdInputName($this->name . '[' . $k . '][modelId]')
64
-                ->setFields($this->fields->clone()->map(function (Field $field) use ($k, $fragment) {
65
-                    return $field->name($this->name . '.' . $k . '.' . $field->getName())
63
+                ->setModelIdInputName($this->name.'['.$k.'][modelId]')
64
+                ->setFields($this->fields->clone()->map(function(Field $field) use ($k, $fragment) {
65
+                    return $field->name($this->name.'.'.$k.'.'.$field->getName())
66 66
                                  ->localizedFormat(':name.:locale')
67
-                                 ->valueResolver(function ($model = null, $locale = null, $field) use ($fragment) {
67
+                                 ->valueResolver(function($model = null, $locale = null, $field) use ($fragment) {
68 68
                                      if (isset($field->value)) {
69 69
                                          return $field->value;
70 70
                                      }
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
         }
111 111
 
112 112
         // Take the fields from the first fragment as a starting point for duplication
113
-        return array_map(function (\Thinktomorrow\Chief\ManagedModels\Fields\Types\Field $field) {
114
-            return $field->valueResolver(function ($model = null, $locale = null, $field) {
113
+        return array_map(function(\Thinktomorrow\Chief\ManagedModels\Fields\Types\Field $field) {
114
+            return $field->valueResolver(function($model = null, $locale = null, $field) {
115 115
                 if ($field instanceof \Thinktomorrow\Chief\ManagedModels\Fields\Types\MediaField) {
116 116
                     return [];
117 117
                 }
Please login to merge, or discard this patch.