@@ -21,16 +21,18 @@ |
||
| 21 | 21 | |
| 22 | 22 | private function processCasting(Attribute $attribute, $value) |
| 23 | 23 | { |
| 24 | - if (($castFunction = $attribute->getCast()) !== null && is_callable($castFunction)) |
|
| 25 | - return $castFunction($value); |
|
| 24 | + if (($castFunction = $attribute->getCast()) !== null && is_callable($castFunction)) { |
|
| 25 | + return $castFunction($value); |
|
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | if ((($type = $attribute->getCast()) !== null && is_string($type)) || |
| 28 | 29 | (is_string($type = $attribute->cast(null)) && in_array(strtolower($type), ["bool", "boolean", "string", "double", "float", "int", "integer", "array", "object"]))) { |
| 29 | 30 | return $this->castFromString($type, $value); |
| 30 | 31 | } |
| 31 | 32 | |
| 32 | - if (!($attribute->cast(null) instanceof Attribute)) |
|
| 33 | - return $attribute->cast($value); |
|
| 33 | + if (!($attribute->cast(null) instanceof Attribute)) { |
|
| 34 | + return $attribute->cast($value); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | return $value; |
| 36 | 38 | } |
@@ -54,8 +54,9 @@ |
||
| 54 | 54 | |
| 55 | 55 | public function cast($cast) |
| 56 | 56 | { |
| 57 | - if (is_callable($cast) || is_string($cast)) |
|
| 58 | - $this->cast = $cast; |
|
| 57 | + if (is_callable($cast) || is_string($cast)) { |
|
| 58 | + $this->cast = $cast; |
|
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | return $this; |
| 61 | 62 | } |