Passed
Push — ft/urls ( cdb8a8...010a18 )
by Ben
26:40
created
src/PageBuilder/PresentSections.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
             $this->addModelToCollection($i, $child);
79 79
         }
80 80
 
81
-        return $this->sets->values()->map(function (ViewableContract $child) {
81
+        return $this->sets->values()->map(function(ViewableContract $child) {
82 82
             return ($this->withSnippets && method_exists($child, 'withSnippets'))
83 83
                 ? $child->withSnippets()->setViewParent($this->parent)->renderView()
84 84
                 : $child->setViewParent($this->parent)->renderView();
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     {
96 96
         // Only published pages you fool!
97 97
         // TODO: check for assistant instead of method existence
98
-        if (method_exists($model, 'isPublished') && ! $model->isPublished()) {
98
+        if (method_exists($model, 'isPublished') && !$model->isPublished()) {
99 99
             return;
100 100
         }
101 101
 
Please login to merge, or discard this patch.
src/Urls/MemoizedUrlRecord.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,14 +8,14 @@
 block discarded – undo
8 8
 {
9 9
     public static function findByModel(Model $model, string $locale = null): UrlRecord
10 10
     {
11
-        return chiefMemoize('url-records-find-by-model', function($model, $locale = null){
11
+        return chiefMemoize('url-records-find-by-model', function($model, $locale = null) {
12 12
             return parent::findByModel($model, $locale);
13 13
         }, [$model, $locale]);
14 14
     }
15 15
 
16 16
     public static function getByModel(Model $model)
17 17
     {
18
-        return chiefMemoize('url-records-get-by-model', function($model){
18
+        return chiefMemoize('url-records-get-by-model', function($model) {
19 19
             return parent::getByModel($model);
20 20
         }, [$model]);
21 21
     }
Please login to merge, or discard this patch.
src/Urls/ChiefResponse.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,41 +14,41 @@
 block discarded – undo
14 14
 {
15 15
     public static function fromRequest(Request $request = null, $locale = null)
16 16
     {
17
-        if(!$request) $request = request();
18
-        if(!$locale) $locale = app()->getLocale();
17
+        if (!$request) $request = request();
18
+        if (!$locale) $locale = app()->getLocale();
19 19
 
20 20
         return static::fromSlug($request->path(), $locale);
21 21
     }
22 22
 
23 23
     public static function fromSlug(string $slug, $locale = null)
24 24
     {
25
-        if(!$locale) $locale = app()->getLocale();
25
+        if (!$locale) $locale = app()->getLocale();
26 26
 
27
-        try{
27
+        try {
28 28
             $urlRecord = UrlRecord::findBySlug($slug, $locale);
29 29
 
30 30
             $model = Morphables::instance($urlRecord->model_type)->find($urlRecord->model_id);
31 31
 
32
-            if($urlRecord->isRedirect()){
32
+            if ($urlRecord->isRedirect()) {
33 33
                 return static::createRedirect($model->url($locale));
34 34
             }
35 35
 
36
-            if(method_exists($model, 'isPublished') && ! $model->isPublished()){
36
+            if (method_exists($model, 'isPublished') && !$model->isPublished()) {
37 37
 
38 38
                 /** When admin is logged in and this request is in preview mode, we allow the view */
39
-                if( ! PreviewMode::fromRequest()->check()){
40
-                    throw new NotFoundHttpException('Model found for request ['. $slug .'] but it is not published.');
39
+                if (!PreviewMode::fromRequest()->check()) {
40
+                    throw new NotFoundHttpException('Model found for request ['.$slug.'] but it is not published.');
41 41
                 }
42 42
             }
43 43
 
44 44
             return new static($model->renderView(), 200);
45 45
         }
46
-        catch(UrlRecordNotFound | NotFoundMorphKey $e)
46
+        catch (UrlRecordNotFound | NotFoundMorphKey $e)
47 47
         {
48
-            if(config('thinktomorrow.chief.strict')){ throw $e; }
48
+            if (config('thinktomorrow.chief.strict')) { throw $e; }
49 49
         }
50 50
 
51
-        throw new NotFoundHttpException('No url or model found for request ['. $slug .'] for locale ['.$locale.'].');
51
+        throw new NotFoundHttpException('No url or model found for request ['.$slug.'] for locale ['.$locale.'].');
52 52
     }
53 53
 
54 54
     private static function createRedirect(string $url)
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,15 +14,21 @@  discard block
 block discarded – undo
14 14
 {
15 15
     public static function fromRequest(Request $request = null, $locale = null)
16 16
     {
17
-        if(!$request) $request = request();
18
-        if(!$locale) $locale = app()->getLocale();
17
+        if(!$request) {
18
+            $request = request();
19
+        }
20
+        if(!$locale) {
21
+            $locale = app()->getLocale();
22
+        }
19 23
 
20 24
         return static::fromSlug($request->path(), $locale);
21 25
     }
22 26
 
23 27
     public static function fromSlug(string $slug, $locale = null)
24 28
     {
25
-        if(!$locale) $locale = app()->getLocale();
29
+        if(!$locale) {
30
+            $locale = app()->getLocale();
31
+        }
26 32
 
27 33
         try{
28 34
             $urlRecord = UrlRecord::findBySlug($slug, $locale);
@@ -42,8 +48,7 @@  discard block
 block discarded – undo
42 48
             }
43 49
 
44 50
             return new static($model->renderView(), 200);
45
-        }
46
-        catch(UrlRecordNotFound | NotFoundMorphKey $e)
51
+        } catch(UrlRecordNotFound | NotFoundMorphKey $e)
47 52
         {
48 53
             if(config('thinktomorrow.chief.strict')){ throw $e; }
49 54
         }
Please login to merge, or discard this patch.
src/Urls/UrlSlugField.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@
 block discarded – undo
31 31
 
32 32
     private function rawSlugValue(): string
33 33
     {
34
-        if(!$this->urlRecord) return '';
34
+        if (!$this->urlRecord) return '';
35 35
 
36 36
         $slug = $this->urlRecord->slug;
37 37
 
38
-        if($this->startsWithBaseUrlSegment($slug)){
38
+        if ($this->startsWithBaseUrlSegment($slug)) {
39 39
             $slug = trim(substr($slug, strlen($this->baseUrlSegment)), '/');
40 40
         }
41 41
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@
 block discarded – undo
31 31
 
32 32
     private function rawSlugValue(): string
33 33
     {
34
-        if(!$this->urlRecord) return '';
34
+        if(!$this->urlRecord) {
35
+            return '';
36
+        }
35 37
 
36 38
         $slug = $this->urlRecord->slug;
37 39
 
Please login to merge, or discard this patch.
src/Management/Application/StoringAndUpdatingFields.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
         foreach ($manager->fieldsWithAssistantFields() as $field) {
21 21
 
22 22
             // Custom save methods
23
-            if($this->detectCustomSaveMethods($manager, $field)) continue;
23
+            if ($this->detectCustomSaveMethods($manager, $field)) continue;
24 24
 
25 25
             // Media fields are treated separately
26 26
             if ($field->ofType(FieldType::MEDIA, FieldType::DOCUMENT)) {
27
-                if (! isset($this->saveMethods['_files'])) {
27
+                if (!isset($this->saveMethods['_files'])) {
28 28
                     $this->saveMethods['_files'] = ['field' => new Fields([$field]), 'method' => 'uploadMedia'];
29 29
                     continue;
30 30
                 }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             }
35 35
 
36 36
             // Custom set methods - default is the generic setField() method.
37
-            $methodName = 'set'. ucfirst(camel_case($field->key())) . 'Field';
37
+            $methodName = 'set'.ucfirst(camel_case($field->key())).'Field';
38 38
             (method_exists($manager, $methodName))
39 39
                 ? $manager->$methodName($field, $request)
40 40
                 : $manager->setField($field, $request);
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 
47 47
     protected function detectCustomSaveMethods(Manager $manager, Field $field): bool
48 48
     {
49
-        $saveMethodName = 'save'. ucfirst(camel_case($field->key())) . 'Field';
49
+        $saveMethodName = 'save'.ucfirst(camel_case($field->key())).'Field';
50 50
 
51 51
         // Custom save method on assistant
52
-        foreach($manager->assistants() as $assistant)
52
+        foreach ($manager->assistants() as $assistant)
53 53
         {
54 54
             if (method_exists($assistant, $saveMethodName)) {
55 55
                 $this->saveAssistantMethods[$field->key] = ['field' => $field, 'method' => $saveMethodName, 'assistant' => $assistant];
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@
 block discarded – undo
20 20
         foreach ($manager->fieldsWithAssistantFields() as $field) {
21 21
 
22 22
             // Custom save methods
23
-            if($this->detectCustomSaveMethods($manager, $field)) continue;
23
+            if($this->detectCustomSaveMethods($manager, $field)) {
24
+                continue;
25
+            }
24 26
 
25 27
             // Media fields are treated separately
26 28
             if ($field->ofType(FieldType::MEDIA, FieldType::DOCUMENT)) {
Please login to merge, or discard this patch.
src/Management/Assistants/AssistedManager.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public function isAssistedBy(string $assistant): bool
19 19
     {
20
-        return !! $this->getAssistantClass($assistant);
20
+        return !!$this->getAssistantClass($assistant);
21 21
     }
22 22
 
23 23
     public function assistants(): array
24 24
     {
25 25
         $assistants = [];
26 26
 
27
-        foreach($this->assistants as $assistant){
27
+        foreach ($this->assistants as $assistant) {
28 28
             $assistants[] = $this->assistant($assistant);
29 29
         }
30 30
 
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
      */
41 41
     public function assistant(string $assistant): Assistant
42 42
     {
43
-        if (! $this->isAssistedBy($assistant)) {
44
-            throw new MissingAssistant('No assistant [' . $assistant . '] present on manager ' . get_class($this));
43
+        if (!$this->isAssistedBy($assistant)) {
44
+            throw new MissingAssistant('No assistant ['.$assistant.'] present on manager '.get_class($this));
45 45
         }
46 46
 
47 47
         $instance = app($this->getAssistantClass($assistant));
Please login to merge, or discard this patch.
src/Management/Assistants/UrlAssistant.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 
33 33
     public function manager(Manager $manager)
34 34
     {
35
-        $this->manager  = $manager;
35
+        $this->manager = $manager;
36 36
 
37
-        if(! $manager->model() instanceof ProvidesUrl){
38
-            throw new \Exception('UrlAssistant requires the model interfaced by ' . ProvidesUrl::class . '.');
37
+        if (!$manager->model() instanceof ProvidesUrl) {
38
+            throw new \Exception('UrlAssistant requires the model interfaced by '.ProvidesUrl::class.'.');
39 39
         }
40 40
 
41 41
         $this->model = $manager->model();
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             InputField::make('url-slugs')
60 60
                 ->validation(
61 61
                     [
62
-                        'url-slugs' => ['array', 'min:1', new UniqueUrlSlugRule(($this->model && $this->model->exists) ? $this->model : null),],
62
+                        'url-slugs' => ['array', 'min:1', new UniqueUrlSlugRule(($this->model && $this->model->exists) ? $this->model : null), ],
63 63
                     ],
64 64
                     [],
65 65
                     [
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                         'url-slugs.*' => 'taalspecifieke link',
68 68
                     ])
69 69
                 ->view('chief::back._fields.url-slugs')
70
-                ->viewData(['fields' => UrlSlugFields::fromModel($this->model) ]),
70
+                ->viewData(['fields' => UrlSlugFields::fromModel($this->model)]),
71 71
         ]);
72 72
     }
73 73
 
Please login to merge, or discard this patch.
src/Management/AbstractManager.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
             $this->filters()->apply($builder);
73 73
 
74 74
             $results = $builder->get();
75
-        } else {
75
+        }else {
76 76
             $results = $model::all();
77 77
         }
78 78
 
79
-        return $results->map(function ($model) {
79
+        return $results->map(function($model) {
80 80
             return (new static($this->registration))->manage($model);
81 81
         });
82 82
     }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
     public function guard($verb): Manager
146 146
     {
147
-        if (! $this->can($verb)) {
147
+        if (!$this->can($verb)) {
148 148
             NotAllowedManagerRoute::notAllowedVerb($verb, $this);
149 149
         }
150 150
 
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
     {
167 167
         $fields = $this->fields();
168 168
 
169
-        foreach($this->assistants() as $assistant){
170
-            if( ! method_exists($assistant, 'fields')) continue;
169
+        foreach ($this->assistants() as $assistant) {
170
+            if (!method_exists($assistant, 'fields')) continue;
171 171
 
172 172
             $fields = $fields->merge($assistant->fields());
173 173
         }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
                 // Could be translatable field
206 206
                 if ($this->isTranslatableKey($field)) {
207
-                    $attribute = substr($field, strrpos($field, '.') + 1);
207
+                    $attribute = substr($field, strrpos($field, '.')+1);
208 208
                     $locale = substr($field, strlen('trans.'), 2);
209 209
 
210 210
                     return $this->model->getTranslationFor($attribute, $locale);
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
             // Make our media fields able to be translatable as well...
244 244
             if ($field->ofType(FieldType::MEDIA, FieldType::DOCUMENT)) {
245
-                throw new \Exception('Cannot process the ' . $field->key . ' media field. Currently no support for translatable media files. We should fix this!');
245
+                throw new \Exception('Cannot process the '.$field->key.' media field. Currently no support for translatable media files. We should fix this!');
246 246
             }
247 247
 
248 248
             // Okay so this is a bit odd but since all translations are expected to be inside the trans
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -167,7 +167,9 @@
 block discarded – undo
167 167
         $fields = $this->fields();
168 168
 
169 169
         foreach($this->assistants() as $assistant){
170
-            if( ! method_exists($assistant, 'fields')) continue;
170
+            if( ! method_exists($assistant, 'fields')) {
171
+                continue;
172
+            }
171 173
 
172 174
             $fields = $fields->merge($assistant->fields());
173 175
         }
Please login to merge, or discard this patch.
src/Fields/Fields.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
     public function validate(array $data)
48 48
     {
49 49
         foreach($this->fields as $field){
50
-             $field->validator($data)->validate();
50
+                $field->validator($data)->validate();
51 51
         }
52 52
     }
53 53
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function first(): ?Field
26 26
     {
27
-        if(!$this->any()) return null;
27
+        if (!$this->any()) return null;
28 28
 
29 29
         return reset($this->fields);
30 30
     }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
     public function validate(array $data)
48 48
     {
49
-        foreach($this->fields as $field){
49
+        foreach ($this->fields as $field) {
50 50
              $field->validator($data)->validate();
51 51
         }
52 52
     }
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 
122 122
     public function offsetSet($offset, $value)
123 123
     {
124
-        if (! $value instanceof Field) {
125
-            throw new \InvalidArgumentException('Passed value must be of type ' . Field::class);
124
+        if (!$value instanceof Field) {
125
+            throw new \InvalidArgumentException('Passed value must be of type '.Field::class);
126 126
         }
127 127
 
128 128
         $this->fields[$offset] = $value;
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
     {
143 143
         $keyedFields = [];
144 144
 
145
-        foreach($fields as $field)
145
+        foreach ($fields as $field)
146 146
         {
147 147
             $keyedFields[$field->key] = $field;
148 148
         }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
     private function validateFields(array $fields)
154 154
     {
155
-        array_map(function (Field $field) {
155
+        array_map(function(Field $field) {
156 156
         }, $fields);
157 157
     }
158 158
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@
 block discarded – undo
24 24
 
25 25
     public function first(): ?Field
26 26
     {
27
-        if(!$this->any()) return null;
27
+        if(!$this->any()) {
28
+            return null;
29
+        }
28 30
 
29 31
         return reset($this->fields);
30 32
     }
Please login to merge, or discard this patch.