Completed
Push — master ( a3231e...8de51f )
by Dominik
02:02
created

DateFieldDenormalizer::getDefault()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
    public function __construct(FieldDenormalizerInterface $fieldDenormalizer)
18
    {
19
        $this->fieldDenormalizer = $fieldDenormalizer;
20
    }
21
22
    /**
23
     * @param string                            $path
24
     * @param object                            $object
25
     * @param mixed                             $value
26
     * @param DenormalizerInterface|null        $denormalizer
27
     * @param DenormalizerContextInterface|null $context
28
     */
29
    public function denormalizeField(
30
        string $path,
31
        $object,
32
        $value,
33
        DenormalizerInterface $denormalizer = null,
34
        DenormalizerContextInterface $context = null
35
    ) {
36
        try {
37
            $value = new \DateTime($value);
38
        } 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
        $this->fieldDenormalizer->denormalizeField($path, $object, $value, $denormalizer, $context);
42
    }
43
44
    /**
45
     * @return mixed
46
     */
47
    public function getDefault()
48
    {
49
        return $this->fieldDenormalizer->getDefault();
50
    }
51
}
52