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

CallbackFieldNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

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
    public function __construct(callable $callback)
18
    {
19
        $this->callback = $callback;
20
    }
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
    public function normalizeField(
31
        string $path,
32
        $object,
33
        NormalizerContextInterface $context,
34
        NormalizerInterface $normalizer = null
35
    ) {
36
        $callback = $this->callback;
37
38
        return $callback($path, $object, $context, $normalizer);
39
    }
40
}
41