Test Failed
Push — master ( 7b15c4...7a5412 )
by Dominik
01:48
created

FieldNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 32
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A normalizeField() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization\Normalizer;
6
7
use Chubbyphp\Serialization\Accessor\AccessorInterface;
8
9
final class FieldNormalizer implements FieldNormalizerInterface
10
{
11
    /**
12
     * @var AccessorInterface
13
     */
14
    private $accessor;
15
16
    /**
17
     * @param AccessorInterface $accessor
18
     */
19 1
    public function __construct(AccessorInterface $accessor)
20
    {
21 1
        $this->accessor = $accessor;
22 1
    }
23
24
    /**
25
     * @param string                     $path
26
     * @param object                     $object
27
     * @param NormalizerContextInterface $context
28
     * @param NormalizerInterface|null   $normalizer
29
     *
30
     * @return mixed
31
     */
32 1
    public function normalizeField(
33
        string $path,
34
        $object,
35
        NormalizerContextInterface $context,
36
        NormalizerInterface $normalizer = null
37
    ) {
38 1
        return $this->accessor->getValue($object);
39
    }
40
}
41