Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
42 | public function denormalizeField( |
||
43 | string $path, |
||
44 | $object, |
||
45 | $value, |
||
46 | 5 | DenormalizerContextInterface $context, |
|
47 | DenormalizerInterface $denormalizer = null |
||
48 | ): void { |
||
49 | if (null === $value) { |
||
50 | $this->accessor->setValue($object, $value); |
||
51 | |||
52 | return; |
||
53 | 5 | } |
|
54 | 1 | ||
55 | if (null === $denormalizer) { |
||
56 | 1 | throw DeserializerLogicException::createMissingDenormalizer($path); |
|
57 | } |
||
58 | |||
59 | 4 | if (!is_array($value)) { |
|
60 | 1 | throw DeserializerRuntimeException::createInvalidDataType($path, gettype($value), 'array'); |
|
61 | } |
||
62 | |||
63 | 3 | $relatedObject = $this->accessor->getValue($object) ?? $this->class; |
|
64 | 1 | ||
65 | $this->accessor->setValue($object, $denormalizer->denormalize($relatedObject, $value, $context, $path)); |
||
66 | } |
||
68 |