Test Setup Failed
Push — a-simpler-manager ( c7b435...29c609 )
by Ben
09:30
created
src/ManagedModels/ModelToManagerMap.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function find(string $modelClass): Manager
23 23
     {
24
-        if(!isset($this->map[$modelClass])) {
25
-            throw new \InvalidArgumentException('No manager mapped to model ' . $modelClass .'. Make sure to register the manager.');
24
+        if (!isset($this->map[$modelClass])) {
25
+            throw new \InvalidArgumentException('No manager mapped to model '.$modelClass.'. Make sure to register the manager.');
26 26
         }
27 27
 
28 28
         return app($this->map[$modelClass]);
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function all(): array
32 32
     {
33
-        return array_map(function($managerClass){
33
+        return array_map(function($managerClass) {
34 34
             return app($managerClass);
35 35
         }, $this->map);
36 36
     }
Please login to merge, or discard this patch.
src/Filters/Presets/RadioFilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 
29 29
     protected function viewData(): array
30 30
     {
31
-        return array_merge( parent::viewData(),[
31
+        return array_merge(parent::viewData(), [
32 32
             'options' => $this->options,
33 33
         ]);
34 34
     }
Please login to merge, or discard this patch.
src/PageBuilder/PageBuilder.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,9 @@
 block discarded – undo
107 107
         // Astrotomic translatable
108 108
         if($model instanceof Translatable) {
109 109
             foreach (config('thinktomorrow.chief.locales') as $locale) {
110
-                if(!isset($trans[$locale])) $trans[$locale] = [];
110
+                if(!isset($trans[$locale])) {
111
+                    $trans[$locale] = [];
112
+                }
111 113
 
112 114
                 $trans[$locale] = array_merge($trans[$locale], $model->getTranslation($locale)->toArray());
113 115
             }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 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\PageBuilder;
6 6
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         $availableChildren = AvailableChildren::forParent($model);
42 42
 
43 43
         // Only include modules of this model or shared ones.
44
-        $modules = $availableChildren->onlyModules()->reject(function ($module) use ($model) {
44
+        $modules = $availableChildren->onlyModules()->reject(function($module) use ($model) {
45 45
             return $module->owner_id != null && $module->owner_id != $model->id;
46 46
         });
47 47
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $available_sets = ModelReferencePresenter::toGroupedSelectValues($availableChildren->onlySets())->toArray();
51 51
 
52 52
         // Current sections
53
-        $sections = $model->children()->map(function ($section, $index) use($model) {
53
+        $sections = $model->children()->map(function($section, $index) use($model) {
54 54
 //            if ($section instanceof TranslatableContract) {
55 55
 //
56 56
 //            }
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
         $trans = [];
88 88
 
89 89
         // Has dynamic attributes
90
-        if(public_method_exists($model, 'dynamic')) {
90
+        if (public_method_exists($model, 'dynamic')) {
91 91
             foreach (config('thinktomorrow.chief.locales') as $locale) {
92 92
                 $trans[$locale] = [];
93 93
 
94
-                foreach($model->rawDynamicValues() as $key => $values) {
95
-                    if(is_array($values)) {
96
-                        foreach($values as $dynamicLocale => $dynamicValue) {
97
-                            if($dynamicLocale === $locale) {
94
+                foreach ($model->rawDynamicValues() as $key => $values) {
95
+                    if (is_array($values)) {
96
+                        foreach ($values as $dynamicLocale => $dynamicValue) {
97
+                            if ($dynamicLocale === $locale) {
98 98
                                 $trans[$locale][$key] = $dynamicValue;
99 99
                             }
100 100
                         }
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
         }
105 105
 
106 106
         // Astrotomic translatable
107
-        if($model instanceof Translatable) {
107
+        if ($model instanceof Translatable) {
108 108
             foreach (config('thinktomorrow.chief.locales') as $locale) {
109
-                if(!isset($trans[$locale])) $trans[$locale] = [];
109
+                if (!isset($trans[$locale])) $trans[$locale] = [];
110 110
 
111 111
                 $trans[$locale] = array_merge($trans[$locale], $model->getTranslation($locale)->toArray());
112 112
             }
Please login to merge, or discard this patch.
src/PageBuilder/Relations/Relation.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             ->orderBy('sort', 'ASC')
55 55
             ->get();
56 56
 
57
-        return $relations->map(function (Relation $relation) {
57
+        return $relations->map(function(Relation $relation) {
58 58
             $parent = $relation->parent;
59 59
             $parent->relation = $relation;
60 60
 
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
             ->orderBy('sort', 'ASC')
71 71
             ->get();
72 72
 
73
-        return $relations->map(function (Relation $relation) use ($parent_type, $parent_id) {
73
+        return $relations->map(function(Relation $relation) use ($parent_type, $parent_id) {
74 74
 
75 75
             // It could be that the child itself is soft-deleted, if this is the case, we will ignore it and move on.
76 76
             if (!$child = $relation->child) {
77 77
                 if (!$relation->child()->withTrashed()->first()) {
78 78
                     // If we cannot retrieve it then the relation type is possibly wrong, this is a database inconsistency and should be addressed
79
-                    throw new \DomainException('Corrupt relation reference. Related child [' . $relation->child_type . '@' . $relation->child_id . '] could not be retrieved for parent [' . $parent_type . '@' . $parent_id . ']. Make sure the morph key can resolve to a valid class.');
79
+                    throw new \DomainException('Corrupt relation reference. Related child ['.$relation->child_type.'@'.$relation->child_id.'] could not be retrieved for parent ['.$parent_type.'@'.$parent_id.']. Make sure the morph key can resolve to a valid class.');
80 80
                 }
81 81
 
82 82
                 return null;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         })
89 89
 
90 90
             // In case of soft-deleted entries, this will be null and should be ignored. We make sure that keys are reset in case of removed child
91
-            ->reject(function ($child) {
91
+            ->reject(function($child) {
92 92
                 return is_null($child);
93 93
             })
94 94
             ->values();
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 
106 106
     public static function deleteRelationsOf($type, $id)
107 107
     {
108
-        $relations = static::where(function ($query) use ($type, $id) {
108
+        $relations = static::where(function($query) use ($type, $id) {
109 109
             return $query->where('parent_type', $type)
110 110
                 ->where('parent_id', $id);
111
-        })->orWhere(function ($query) use ($type, $id) {
111
+        })->orWhere(function($query) use ($type, $id) {
112 112
             return $query->where('child_type', $type)
113 113
                 ->where('child_id', $id);
114 114
         })->get();
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
     public static function deleteAllChildRelationsOf($type, $id)
122 122
     {
123
-        $relations = static::where(function ($query) use ($type, $id) {
123
+        $relations = static::where(function($query) use ($type, $id) {
124 124
             return $query->where('parent_type', $type)
125 125
                 ->where('parent_id', $id);
126 126
         })->get();
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
     public static function deleteAllParentRelationsOf($type, $id)
134 134
     {
135
-        $relations = static::where(function ($query) use ($type, $id) {
135
+        $relations = static::where(function($query) use ($type, $id) {
136 136
             return $query->where('child_type', $type)
137 137
                 ->where('child_id', $id);
138 138
         })->get();
Please login to merge, or discard this patch.
src/Mediagallery/Http/MediagalleryController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
         $assets = Asset::with('media')->orderBy('created_at', 'DESC')->select('assets.*');
22 22
 
23 23
         if ($search) {
24
-            $assets->whereHas('media', function (Builder $query) use ($search) {
25
-                $query->where('file_name', 'LIKE', '%' . $search . '%');
24
+            $assets->whereHas('media', function(Builder $query) use ($search) {
25
+                $query->where('file_name', 'LIKE', '%'.$search.'%');
26 26
             });
27 27
         }
28 28
 
29 29
         if ($unused) {
30
-            $assets->whereNotExists(function ($query) {
30
+            $assets->whereNotExists(function($query) {
31 31
                 $query->select(DB::raw(1))
32 32
                     ->from('asset_pivots')
33 33
                     ->whereRaw('asset_pivots.asset_id = assets.id')
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
             });
36 36
         }
37 37
 
38
-        if($owner){
38
+        if ($owner) {
39 39
             $owner = ModelReference::fromString($owner)->instance();
40 40
             $modelAssets = collect();
41 41
             $modelAssets = $modelAssets->merge($owner->assets());
Please login to merge, or discard this patch.
src/Settings/Application/ChangeHomepage.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
     {
55 55
         foreach ($modelReferences as $locale => $modelReferenceString) {
56 56
             if (!$modelReferenceString) {
57
-                throw new \InvalidArgumentException('Homepage setting value cannot be empty. Value for locale ' . $locale . ' is missing.');
57
+                throw new \InvalidArgumentException('Homepage setting value cannot be empty. Value for locale '.$locale.' is missing.');
58 58
             }
59 59
         }
60 60
     }
Please login to merge, or discard this patch.
src/ModelReferences/ModelReferencePresenter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 {
11 11
     public static function toSelectValues(Collection $collection): Collection
12 12
     {
13
-        return $collection->map(function (ProvidesModelReference $item) {
13
+        return $collection->map(function(ProvidesModelReference $item) {
14 14
             return [
15 15
                 'id'    => $item->modelReference()->get(),
16 16
                 'label' => $item->modelReferenceLabel(),
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
     {
24 24
         $grouped = [];
25 25
 
26
-        static::toSelectValues($collection)->each(function ($item) use (&$grouped) {
26
+        static::toSelectValues($collection)->each(function($item) use (&$grouped) {
27 27
             if (isset($grouped[$item['group']])) {
28 28
                 $grouped[$item['group']]['values'][] = $item;
29
-            } else {
29
+            }else {
30 30
                 $grouped[$item['group']] = ['group' => $item['group'], 'values' => [$item]];
31 31
             }
32 32
         });
Please login to merge, or discard this patch.
src/ModelReferences/ModelReferenceCollection.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,16 +21,16 @@
 block discarded – undo
21 21
             $referenceStrings = [];
22 22
         }
23 23
 
24
-        return (new Collection($referenceStrings))->reject(function ($referenceString) {
24
+        return (new Collection($referenceStrings))->reject(function($referenceString) {
25 25
             return is_null($referenceString);
26
-        })->map(function ($referenceString) {
26
+        })->map(function($referenceString) {
27 27
             return ModelReference::fromString($referenceString)->instance();
28 28
         });
29 29
     }
30 30
 
31 31
     public function toModelReferences(): Collection
32 32
     {
33
-        return (new Collection($this->all()))->map(function (ProvidesModelReference $item) {
33
+        return (new Collection($this->all()))->map(function(ProvidesModelReference $item) {
34 34
             return $item->modelReference()->get();
35 35
         });
36 36
     }
Please login to merge, or discard this patch.
src/ModelReferences/ModelReference.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
     public static function fromString(string $reference): self
22 22
     {
23 23
         if (false == strpos($reference, '@')) {
24
-            throw new \InvalidArgumentException('Invalid reference composition. A model reference should honour schema <class>@<id>. [' . $reference . '] was passed instead.');
24
+            throw new \InvalidArgumentException('Invalid reference composition. A model reference should honour schema <class>@<id>. ['.$reference.'] was passed instead.');
25 25
         }
26 26
 
27 27
         list($className, $id) = explode('@', $reference);
28 28
 
29
-        return new static($className, (int) $id);
29
+        return new static($className, (int)$id);
30 30
     }
31 31
 
32 32
     /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
     public function get(): string
53 53
     {
54
-        return $this->className . '@' . $this->id;
54
+        return $this->className.'@'.$this->id;
55 55
     }
56 56
 
57 57
     public function equals($other): bool
Please login to merge, or discard this patch.