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

CallbackFieldNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 34
ccs 6
cts 6
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 10 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