Total Complexity | 7 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
11 | final class MysqlColumnSchema extends ColumnSchema |
||
12 | { |
||
13 | /** |
||
14 | * Converts the input value according to {@see phpType} after retrieval from the database. |
||
15 | * |
||
16 | * If the value is null or an {@see Expression}, it will not be converted. |
||
17 | * |
||
18 | * @param mixed $value input value. |
||
19 | * |
||
20 | * @return mixed converted value. |
||
21 | */ |
||
22 | public function phpTypecast($value) |
||
23 | { |
||
24 | if ($value === null) { |
||
25 | return; |
||
26 | } |
||
27 | |||
28 | if ($this->getType() === MysqlSchema::TYPE_JSON) { |
||
29 | return \json_decode($value, true, 512, JSON_THROW_ON_ERROR); |
||
30 | } |
||
31 | |||
32 | return parent::phpTypecast($value); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Converts the input value according to {@see type} and {@see dbType} for use in a db query. |
||
37 | * |
||
38 | * If the value is null or an {@see Expression}, it will not be converted. |
||
39 | * |
||
40 | * @param mixed $value input value. |
||
41 | * |
||
42 | * @return mixed converted value. This may also be an array containing the value as the first element and the PDO |
||
43 | * type as the second element. |
||
44 | */ |
||
45 | public function dbTypecast($value) |
||
60 | } |
||
61 | } |
||
62 |