| Conditions | 6 |
| Paths | 6 |
| Total Lines | 26 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 12 | public function denormalizeField( |
|
| 34 | string $path, |
||
| 35 | $object, |
||
| 36 | $value, |
||
| 37 | DenormalizerContextInterface $context, |
||
| 38 | DenormalizerInterface $denormalizer = null |
||
| 39 | ) { |
||
| 40 | 12 | if (!is_string($value) || '' === $trimmedValue = trim($value)) { |
|
| 41 | 6 | $this->fieldDenormalizer->denormalizeField($path, $object, $value, $context, $denormalizer); |
|
| 42 | |||
| 43 | 6 | return; |
|
| 44 | } |
||
| 45 | |||
| 46 | try { |
||
| 47 | 6 | $dateTime = new \DateTime($trimmedValue); |
|
| 48 | 3 | $errors = \DateTime::getLastErrors(); |
|
| 49 | |||
| 50 | 3 | if (0 === $errors['warning_count'] && 0 === $errors['error_count']) { |
|
| 51 | 3 | $value = $dateTime; |
|
| 52 | } |
||
| 53 | 3 | } catch (\Exception $exception) { |
|
| 54 | 3 | error_clear_last(); |
|
| 55 | } |
||
| 56 | |||
| 57 | 6 | $this->fieldDenormalizer->denormalizeField($path, $object, $value, $context, $denormalizer); |
|
| 58 | 6 | } |
|
| 59 | } |
||
| 60 |