| Conditions | 7 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 43 | public function getValue(ResourceInterface $resource, $value) |
||
| 44 | { |
||
| 45 | if ($value === null || !$this->className) { |
||
| 46 | return $value; |
||
| 47 | } elseif ($this->isList && is_array($value)) { |
||
| 48 | $array = []; |
||
| 49 | foreach ($value as $subVal) { |
||
| 50 | $array[] = $resource->model($this->className, $subVal); |
||
| 51 | } |
||
| 52 | return $array; |
||
| 53 | } elseif ($this->className === \DateTimeImmutable::class) { |
||
| 54 | return new \DateTimeImmutable($value); |
||
| 55 | } |
||
| 56 | |||
| 57 | return $resource->model($this->className, $value); |
||
| 58 | } |
||
| 59 | } |
||
| 60 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: