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

FieldNormalizer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 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