Conditions | 5 |
Paths | 4 |
Total Lines | 26 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 5 |
Changes | 4 | ||
Bugs | 3 | Features | 2 |
1 | <?php |
||
43 | public function denormalizeField( |
||
44 | string $path, |
||
45 | $object, |
||
46 | $value, |
||
47 | DenormalizerContextInterface $context, |
||
48 | DenormalizerInterface $denormalizer = null |
||
49 | ): void { |
||
50 | if ('' === $value && $this->emptyToNull) { |
||
51 | 6 | $this->accessor->setValue($object, null); |
|
52 | |||
53 | return; |
||
54 | } |
||
55 | |||
56 | if (null === $value) { |
||
57 | $this->accessor->setValue($object, null); |
||
58 | 6 | ||
59 | 1 | return; |
|
60 | } |
||
61 | 1 | ||
62 | if (!is_string($value)) { |
||
63 | throw DeserializerRuntimeException::createInvalidDataType($path, gettype($value), 'string'); |
||
64 | 5 | } |
|
65 | 1 | ||
66 | $repository = $this->repository; |
||
67 | 1 | ||
68 | $this->accessor->setValue($object, $repository($value) ?? $value); |
||
69 | } |
||
71 |