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

FieldNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

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
    public function __construct(AccessorInterface $accessor)
20
    {
21
        $this->accessor = $accessor;
22
    }
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
    public function normalizeField(
33
        string $path,
34
        $object,
35
        NormalizerContextInterface $context,
36
        NormalizerInterface $normalizer = null
37
    ) {
38
        return $this->accessor->getValue($object);
39
    }
40
}
41