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

CallbackFieldNormalizer::normalizeField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 4
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization\Normalizer;
6
7
final class CallbackFieldNormalizer implements FieldNormalizerInterface
8
{
9
    /**
10
     * @var callable
11
     */
12
    private $callback;
13
14
    /**
15
     * @param callable $callback
16
     */
17 1
    public function __construct(callable $callback)
18
    {
19 1
        $this->callback = $callback;
20 1
    }
21
22
    /**
23
     * @param string                     $path
24
     * @param object                     $object
25
     * @param NormalizerContextInterface $context
26
     * @param NormalizerInterface|null   $normalizer
27
     *
28
     * @return mixed
29
     */
30 1
    public function normalizeField(
31
        string $path,
32
        $object,
33
        NormalizerContextInterface $context,
34
        NormalizerInterface $normalizer = null
35
    ) {
36 1
        $callback = $this->callback;
37
38 1
        return $callback($path, $object, $context, $normalizer);
39
    }
40
}
41