Test Failed
Push — master ( 8a2b60...8e4848 )
by Dominik
03:00
created

DateFieldNormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 44
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A normalizeField() 0 14 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization\Normalizer;
6
7
final class DateFieldNormalizer implements FieldNormalizerInterface
8
{
9
    /**
10
     * @var FieldNormalizerInterface
11
     */
12
    private $fieldNormalizer;
13
14
    /**
15
     * @var string
16
     */
17
    private $format;
18
19
    /**
20
     * @param FieldNormalizerInterface $fieldNormalizer
21
     */
22
    public function __construct(FieldNormalizerInterface $fieldNormalizer)
23
    {
24
        $this->fieldNormalizer = $fieldNormalizer;
25
    }
26
27
    /**
28
     * @param string                     $path
29
     * @param object                     $object
30
     * @param mixed                      $value
0 ignored issues
show
Bug introduced by
There is no parameter named $value. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
31
     * @param NormalizerContextInterface $context
32
     * @param NormalizerInterface|null   $normalizer
33
     *
34
     * @return mixed
35
     */
36
    public function normalizeField(
37
        string $path,
38
        $object,
39
        NormalizerContextInterface $context,
40
        NormalizerInterface $normalizer = null
41
    ) {
42
        $value = $this->fieldNormalizer->normalizeField($path, $object, $context, $normalizer);
43
44
        if (!$value instanceof \DateTimeInterface) {
45
            return $value;
46
        }
47
48
        return $value->format($this->format);
49
    }
50
}
51