Conditions | 7 |
Paths | 5 |
Total Lines | 18 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
53 | public function getValue(ResourceInterface $resource, $value) |
||
54 | { |
||
55 | $class = $this->_className; |
||
56 | |||
57 | if ($value === null || !$class) { |
||
58 | return $value; |
||
59 | } elseif ($this->_isList && is_array($value)) { |
||
60 | $array = []; |
||
61 | foreach ($value as $subVal) { |
||
62 | $array[] = $resource->model($class, $subVal); |
||
63 | } |
||
64 | return $array; |
||
65 | } elseif ($class === \DateTimeImmutable::class) { |
||
66 | return new \DateTimeImmutable($value); |
||
67 | } |
||
68 | |||
69 | return $resource->model($class, $value); |
||
70 | } |
||
71 | } |
||
72 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: