Completed
Push — master ( d8a1ad...d0379b )
by Dominik
02:06
created

DateFieldDenormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 37
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A denormalizeField() 0 14 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