Conditions | 5 |
Paths | 7 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function cast($type, $value, ...$args) |
||
19 | { |
||
20 | if ($value === null) { |
||
21 | return null; |
||
22 | } |
||
23 | |||
24 | if (strpos($type, ':')) { |
||
25 | list($cast, $args) = explode(':', $type); |
||
26 | $args = explode(',', $args); |
||
27 | } else { |
||
28 | $cast = $type; |
||
29 | } |
||
30 | |||
31 | if (method_exists($this, $cast)) { |
||
32 | return $this->$cast($value, ...$args); |
||
33 | } |
||
34 | |||
35 | if (isset($this->casts[$cast])) { |
||
36 | $func = $this->casts[$cast]; |
||
37 | |||
38 | return $func($value, ...$args); |
||
39 | } |
||
40 | |||
41 | return $value; |
||
42 | } |
||
64 |