Passed
Push — master ( 82657f...9be19c )
by Dominik
01:56
created

DateFieldDenormalizer::denormalizeField()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 5
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Deserialization\Denormalizer;
6
7
final class DateFieldDenormalizer implements FieldDenormalizerInterface
8
{
9
    /**
10
     * @var FieldDenormalizerInterface
11
     */
12
    private $fieldDenormalizer;
13
14
    /**
15
     * @param FieldDenormalizerInterface $fieldDenormalizer
16
     */
17 2
    public function __construct(FieldDenormalizerInterface $fieldDenormalizer)
18
    {
19 2
        $this->fieldDenormalizer = $fieldDenormalizer;
20 2
    }
21
22
    /**
23
     * @param string                       $path
24
     * @param object                       $object
25
     * @param mixed                        $value
26
     * @param DenormalizerContextInterface $context
27
     * @param DenormalizerInterface|null   $denormalizer
28
     */
29 2
    public function denormalizeField(
30
        string $path,
31
        $object,
32
        $value,
33
        DenormalizerContextInterface $context,
34
        DenormalizerInterface $denormalizer = null
35
    ) {
36
        try {
37 2
            $value = new \DateTime($value);
38 1
        } catch (\Exception $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
39
        }
40
41 2
        $this->fieldDenormalizer->denormalizeField($path, $object, $value, $context, $denormalizer);
42 2
    }
43
}
44