Test Setup Failed
Push — a-simpler-manager ( 9beba5...d99f82 )
by Ben
06:26
created
src/Old/PageBuilder/PageBuilder.php 2 patches
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\Old\PageBuilder;
6 6
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $availableChildren = AvailableChildren::forParent($model);
43 43
 
44 44
         // Only include modules of this model or shared ones.
45
-        $modules = $availableChildren->onlyModules()->reject(function ($module) use ($model) {
45
+        $modules = $availableChildren->onlyModules()->reject(function($module) use ($model) {
46 46
             return $module->owner_id != null && $module->owner_id != $model->id;
47 47
         });
48 48
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $available_sets = ModelReferencePresenter::toGroupedSelectValues($availableChildren->onlySets())->toArray();
52 52
 
53 53
         // Current sections
54
-        $sections = $model->children()->map(function ($section, $index) use($model) {
54
+        $sections = $model->children()->map(function($section, $index) use($model) {
55 55
 //            if ($section instanceof TranslatableContract) {
56 56
 //
57 57
 //            }
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
         $trans = [];
89 89
 
90 90
         // Has dynamic attributes
91
-        if(public_method_exists($model, 'dynamic')) {
91
+        if (public_method_exists($model, 'dynamic')) {
92 92
             foreach (config('thinktomorrow.chief.locales') as $locale) {
93 93
                 $trans[$locale] = [];
94 94
 
95
-                foreach($model->rawDynamicValues() as $key => $values) {
96
-                    if(is_array($values)) {
97
-                        foreach($values as $dynamicLocale => $dynamicValue) {
98
-                            if($dynamicLocale === $locale) {
95
+                foreach ($model->rawDynamicValues() as $key => $values) {
96
+                    if (is_array($values)) {
97
+                        foreach ($values as $dynamicLocale => $dynamicValue) {
98
+                            if ($dynamicLocale === $locale) {
99 99
                                 $trans[$locale][$key] = $dynamicValue;
100 100
                             }
101 101
                         }
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
         }
106 106
 
107 107
         // Astrotomic translatable
108
-        if($model instanceof Translatable) {
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])) $trans[$locale] = [];
111 111
 
112 112
                 $trans[$locale] = array_merge($trans[$locale], $model->getTranslation($locale)->toArray());
113 113
             }
Please login to merge, or discard this patch.
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.
src/Old/PageBuilder/UpdateSections.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                 continue;
195 195
             }
196 196
 
197
-            $child = $children->first(function ($c) use ($reference) {
197
+            $child = $children->first(function($c) use ($reference) {
198 198
                 return $c->modelReference()->get() == $reference;
199 199
             });
200 200
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     private function stripTagsBlacklist($value, $blacklist = [])
246 246
     {
247 247
         foreach ($blacklist as $tag) {
248
-            $value = preg_replace('/<\/?' . $tag . '(.|\s)*?>/', '', $value);
248
+            $value = preg_replace('/<\/?'.$tag.'(.|\s)*?>/', '', $value);
249 249
         }
250 250
 
251 251
         return $value;
Please login to merge, or discard this patch.
src/Old/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/Old/PageBuilder/Relations/AvailableChildren.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function onlyModules(): Collection
36 36
     {
37
-        return $this->collection()->reject(function ($item) {
37
+        return $this->collection()->reject(function($item) {
38 38
             return ($item instanceof ActsAsParent);
39 39
         });
40 40
     }
41 41
 
42 42
     public function onlyPages(): Collection
43 43
     {
44
-        return $this->collection()->filter(function ($item) {
44
+        return $this->collection()->filter(function($item) {
45 45
             return ($item instanceof ActsAsParent);
46 46
         });
47 47
     }
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 //        }
97 97
 
98 98
         // Remove duplicate models
99
-        $collection = $collection->unique(function ($model) {
99
+        $collection = $collection->unique(function($model) {
100 100
             return (new ModelReference(get_class($model), $model->id))->get();
101 101
         });
102 102
 
103 103
         // Filter out our parent
104
-        return $this->collection = $collection->reject(function ($item) {
104
+        return $this->collection = $collection->reject(function($item) {
105 105
             return ($item instanceof $this->parent && $item->id == $this->parent->id);
106 106
         })->values();
107 107
     }
Please login to merge, or discard this patch.
src/Old/Snippets/SnippetCollection.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             }
37 37
         }
38 38
 
39
-        return static::$loadedSnippets = new self($files->map(function (SplFileInfo $file) {
39
+        return static::$loadedSnippets = new self($files->map(function(SplFileInfo $file) {
40 40
             $path = $file->getRealPath();
41 41
 
42 42
             if (0 === strpos($path, resource_path('views')) && false !== strpos($file->getBasename(), '.blade.php')) {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $loadedSnippets = static::load();
56 56
 
57
-        return $loadedSnippets->first(function (Snippet $snippet) use ($key) {
57
+        return $loadedSnippets->first(function(Snippet $snippet) use ($key) {
58 58
             return $snippet->key() == $key;
59 59
         });
60 60
     }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
     public function toClips(): array
87 87
     {
88
-        return $this->map(function ($snippet) {
88
+        return $this->map(function($snippet) {
89 89
             return [$snippet->label(), $snippet->placeholder()];
90 90
         })->toArray();
91 91
     }
Please login to merge, or discard this patch.
src/Old/Snippets/SnippetParser.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
             return $value;
13 13
         }
14 14
 
15
-        $value = preg_replace_callback(static::$pattern, function ($matches) {
15
+        $value = preg_replace_callback(static::$pattern, function($matches) {
16 16
 
17 17
             // First entry of matches contains our full captured group, which we want to replace.
18 18
             // Second entry is the text itself, without the brackets
Please login to merge, or discard this patch.
src/Site/Menu/Application/UpdateMenu.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
         if (in_array($menu->order, $sequence)) {
55 55
             foreach ($sequence as $id => $order) {
56 56
                 if ($order < $menu->order) {
57
-                } else {
57
+                }else {
58 58
                     $sequence[$id]++;
59 59
                 }
60 60
             }
61 61
         }
62 62
 
63
-        $sequence = $sequence + [$menu->id => $menu->order];
63
+        $sequence = $sequence+[$menu->id => $menu->order];
64 64
 
65 65
         asort($sequence);
66 66
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
     private function reorder(array $sequence)
71 71
     {
72
-        array_walk($sequence, function ($order, $id) {
72
+        array_walk($sequence, function($order, $id) {
73 73
             MenuItem::withoutGlobalScope(SoftDeletingScope::class)
74 74
                 ->where('id', $id)
75 75
                 ->update(['order' => $order]);
Please login to merge, or discard this patch.
src/Site/Menu/MenuItem.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             if ($item->ofType(static::TYPE_INTERNAL) && $page = $item->page) {
105 105
                 if (public_method_exists($page, 'isArchived') && $page->isArchived()) {
106 106
                     unset($items[$k]);
107
-                } else {
107
+                }else {
108 108
                     $item->url = self::composePageUrl($item, $page);
109 109
                     $item->page_label = public_method_exists($page, 'menuLabel') ? $page->menuLabel() : '';
110 110
                     $item->hidden_in_menu = $page->hidden_in_menu;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             'id'             => $node->id,
154 154
             'type'           => $node->type,
155 155
             'label'          => $node->label,
156
-            'page_label'     => $node->page_label,                       // Extra info when dealing with internal links
156
+            'page_label'     => $node->page_label, // Extra info when dealing with internal links
157 157
             'url'            => $node->url,
158 158
             'order'          => $node->order,
159 159
             'page_id'        => $node->page_id,
Please login to merge, or discard this patch.
src/Site/Menu/Menu.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $types = config('thinktomorrow.chief.menus', []);
28 28
 
29
-        return collect($types)->map(function ($menu, $key) {
29
+        return collect($types)->map(function($menu, $key) {
30 30
             return new static($key, $menu['label'], $menu['view']);
31 31
         });
32 32
     }
33 33
 
34 34
     public static function find($key): ?self
35 35
     {
36
-        return static::all()->filter(function ($menu) use ($key) {
36
+        return static::all()->filter(function($menu) use ($key) {
37 37
             return $menu->key() == $key;
38 38
         })->first();
39 39
     }
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $menu = [];
84 84
 
85
-        $this->items()->each(function ($item) use (&$menu) {
85
+        $this->items()->each(function($item) use (&$menu) {
86 86
             $menu[] = sprintf('<li><a href="%s">%s</a></li>', $item->url, $item->label);
87 87
         });
88 88
 
89
-        return '<ul>' . implode('', $menu) . '</ul>';
89
+        return '<ul>'.implode('', $menu).'</ul>';
90 90
     }
91 91
 }
Please login to merge, or discard this patch.