Conditions | 7 |
Paths | 7 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
41 | public static function cast(string $type, $value) |
||
42 | { |
||
43 | if (in_array($type, self::INTEGER_TYPES, true)) { |
||
44 | return (int) $value; |
||
45 | } |
||
46 | |||
47 | if (in_array($type, self::BOOLEAN_TYPES, true)) { |
||
48 | return (bool) $value; |
||
49 | } |
||
50 | |||
51 | if (in_array($type, self::FLOAT_TYPES, true)) { |
||
52 | return (float) $value; |
||
53 | } |
||
54 | |||
55 | if ($type === self::TYPE_STRING) { |
||
56 | return (string) $value; |
||
57 | } |
||
58 | |||
59 | if ($type === self::TYPE_ARRAY) { |
||
60 | return (array) $value; |
||
61 | } |
||
62 | |||
63 | if ($type === self::TYPE_OBJECT) { |
||
64 | return (object) $value; |
||
65 | } |
||
66 | |||
67 | return $value; |
||
68 | } |
||
69 | |||
86 |