Passed
Push — ft/dynamic-attributes ( 48373f...169e79 )
by Ben
06:24
created
src/DynamicAttributes/DynamicAttributes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     {
18 18
         $value = is_null($value) ? [] : (is_array($value) ? $value : json_decode($value, true));
19 19
 
20
-        return new static((array) $value);
20
+        return new static((array)$value);
21 21
     }
22 22
 
23 23
     public function has(string $key): bool
Please login to merge, or discard this patch.
src/DynamicAttributes/HasDynamicAttributes.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
     public function isDynamicAttributeKey($key): bool
19 19
     {
20
-        if(array_key_exists($key, $this->attributes)) {
20
+        if (array_key_exists($key, $this->attributes)) {
21 21
             return false;
22 22
         }
23 23
 
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
     /* Part of the custom cast */
72 72
     public function getAttribute($key)
73 73
     {
74
-        if (!$this->isDynamicAttributeKey($key)){
74
+        if (!$this->isDynamicAttributeKey($key)) {
75 75
             return parent::getAttribute($key);
76 76
         }
77 77
 
78 78
         $locale = app()->getLocale();
79 79
 
80 80
         // If the dynamic attributes contain a localized value, this has preference over any non-localized.
81
-        foreach(["{$locale}.$key", $key] as $k){
82
-            if($this->dynamicAttributesInstance()->has($k)){
81
+        foreach (["{$locale}.$key", $key] as $k) {
82
+            if ($this->dynamicAttributesInstance()->has($k)) {
83 83
                 return $this->dynamic($k);
84 84
             }
85 85
         }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     /* Part of the custom cast */
91 91
     public function setAttribute($key, $value)
92 92
     {
93
-        if ($this->isDynamicAttributeKey($key)){
93
+        if ($this->isDynamicAttributeKey($key)) {
94 94
             return $this->setDynamic($key, $value);
95 95
         }
96 96
 
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
     /* Part of the custom cast */
101 101
     protected function dynamicAttributesInstance(): DynamicAttributes
102 102
     {
103
-        if(!isset($this->attributes[$this->getDynamicAttributesKey()])) {
103
+        if (!isset($this->attributes[$this->getDynamicAttributesKey()])) {
104 104
             $this->attributes[$this->getDynamicAttributesKey()] = DynamicAttributes::fromRawValue([]);
105
-        } elseif(!($raw = $this->attributes[$this->getDynamicAttributesKey()]) instanceof DynamicAttributes) {
105
+        } elseif (!($raw = $this->attributes[$this->getDynamicAttributesKey()]) instanceof DynamicAttributes) {
106 106
             $this->attributes[$this->getDynamicAttributesKey()] = DynamicAttributes::fromRawValue($raw);
107 107
         }
108 108
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     private function injectDynamicAttributes(array $attributes, bool $castToObject = true): array
121 121
     {
122
-        if(isset($attributes[$this->getDynamicAttributesKey()])) {
122
+        if (isset($attributes[$this->getDynamicAttributesKey()])) {
123 123
             $attributes[$this->getDynamicAttributesKey()] = $castToObject
124 124
                 ? DynamicAttributes::fromRawValue($attributes[$this->getDynamicAttributesKey()])
125 125
                 : $attributes[$this->getDynamicAttributesKey()]->toJson();
Please login to merge, or discard this patch.
src/Fields/Types/AbstractField.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
      */
240 240
     private function defaultEloquentValueResolver(): \Closure
241 241
     {
242
-        return function (Model $model = null, $locale = null) {
242
+        return function(Model $model = null, $locale = null) {
243 243
             if (!$model) {
244 244
                 return $this->value;
245 245
             }
246 246
 
247 247
             if ($locale && $this->isLocalized()) {
248
-                if(method_exists($model, 'isDynamicAttributeKey') && $model->isDynamicAttributeKey($this->getColumn())){
248
+                if (method_exists($model, 'isDynamicAttributeKey') && $model->isDynamicAttributeKey($this->getColumn())) {
249 249
                     return $model->dynamic($this->getColumn(), $locale);
250 250
                 }
251 251
 
@@ -404,6 +404,6 @@  discard block
 block discarded – undo
404 404
 
405 405
         return $this->isLocalized()
406 406
             ? 'chief::back._fields.translatable'
407
-            : 'chief::back._fields.' . $this->type->get();
407
+            : 'chief::back._fields.'.$this->type->get();
408 408
     }
409 409
 }
Please login to merge, or discard this patch.
src/Fields/SavingFields.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
             }
32 32
 
33 33
             // Custom set methods - default is the generic setField() method.
34
-            $methodName = 'set' . ucfirst(Str::camel($field->getKey())) . 'Field';
34
+            $methodName = 'set'.ucfirst(Str::camel($field->getKey())).'Field';
35 35
             (method_exists($this, $methodName))
36 36
                 ? $this->$methodName($field, $request)
37 37
                 : $this->setField($field, $request);
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 
49 49
     protected function detectCustomSaveMethods(Field $field): bool
50 50
     {
51
-        $saveMethodByKey = 'save' . ucfirst(Str::camel($field->getKey())) . 'Field';
52
-        $saveMethodByType = 'save' . ucfirst(Str::camel($field->getType()->get())) . 'Fields';
51
+        $saveMethodByKey = 'save'.ucfirst(Str::camel($field->getKey())).'Field';
52
+        $saveMethodByType = 'save'.ucfirst(Str::camel($field->getType()->get())).'Fields';
53 53
 
54 54
         foreach ([$saveMethodByKey, $saveMethodByType] as $saveMethod) {
55 55
             foreach ($this->assistants() as $assistant) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
             // Make our media fields able to be translatable as well...
98 98
             if ($field->ofType(FieldType::FILE, FieldType::IMAGE)) {
99
-                throw new \Exception('Cannot process the ' . $field->getKey() . ' media field. Currently no support for translatable media files. We should fix this!');
99
+                throw new \Exception('Cannot process the '.$field->getKey().' media field. Currently no support for translatable media files. We should fix this!');
100 100
             }
101 101
 
102 102
             // Okay so this is a bit odd but since all translations are expected to be inside the trans
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
     {
117 117
         $queued_translations = $this->queued_translations;
118 118
 
119
-        foreach($queued_translations as $locale => $translations){
120
-            foreach($translations as $key => $value) {
121
-                if(method_exists($this->model, 'isDynamicAttributeKey') && $this->model->isDynamicAttributeKey($key)) {
119
+        foreach ($queued_translations as $locale => $translations) {
120
+            foreach ($translations as $key => $value) {
121
+                if (method_exists($this->model, 'isDynamicAttributeKey') && $this->model->isDynamicAttributeKey($key)) {
122 122
                     $this->model->setDynamic($key, $value, $locale);
123 123
 
124 124
                     // Remove from queued translations
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                 }
127 127
 
128 128
                 // remove any empty locale entries
129
-                if(empty($queued_translations[$locale])) {
129
+                if (empty($queued_translations[$locale])) {
130 130
                     unset($queued_translations[$locale]);
131 131
                 }
132 132
             }
Please login to merge, or discard this patch.