@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | protected function resolveAttributeCasting(array $data) |
11 | 11 | { |
12 | 12 | return collect($this->rules()) |
13 | - ->filter(function ($rule) { |
|
13 | + ->filter(function($rule) { |
|
14 | 14 | return $rule instanceof Attribute; |
15 | 15 | }) |
16 | - ->intersectByKeys($data)->map(function (Attribute $attribute, $key) use ($data) { |
|
16 | + ->intersectByKeys($data)->map(function(Attribute $attribute, $key) use ($data) { |
|
17 | 17 | return $this->processCasting($attribute, $data[$key]); |
18 | 18 | })->toArray(); |
19 | 19 | } |
@@ -44,20 +44,20 @@ discard block |
||
44 | 44 | switch (strtolower($type)) { |
45 | 45 | case 'boolean': |
46 | 46 | case 'bool': |
47 | - return (bool)$value; |
|
47 | + return (bool) $value; |
|
48 | 48 | case 'string': |
49 | - return (string)$value; |
|
49 | + return (string) $value; |
|
50 | 50 | case 'double': |
51 | - return (float)$value; |
|
51 | + return (float) $value; |
|
52 | 52 | case 'integer': |
53 | 53 | case 'int': |
54 | - return (int)$value; |
|
54 | + return (int) $value; |
|
55 | 55 | case 'float': |
56 | - return (float)$value; |
|
56 | + return (float) $value; |
|
57 | 57 | case 'array': |
58 | - return (array)$value; |
|
58 | + return (array) $value; |
|
59 | 59 | case 'object': |
60 | - return (object)$value; |
|
60 | + return (object) $value; |
|
61 | 61 | default: |
62 | 62 | throw new \RuntimeException('cast type not supported'); |
63 | 63 | } |
@@ -20,8 +20,9 @@ |
||
20 | 20 | |
21 | 21 | private function processCasting(Attribute $attribute, $value) |
22 | 22 | { |
23 | - if ($attribute->isNullable() && $value === null) |
|
24 | - return $value; |
|
23 | + if ($attribute->isNullable() && $value === null) { |
|
24 | + return $value; |
|
25 | + } |
|
25 | 26 | |
26 | 27 | if (($castFunction = $attribute->getCast()) !== null && is_callable($castFunction)) { |
27 | 28 | return $castFunction($value); |