Passed
Push — master ( 447157...f66c71 )
by Dominik
01:59
created

CallbackFieldDenormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
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 36
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A denormalizeField() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Deserialization\Denormalizer;
6
7
use Chubbyphp\Deserialization\DeserializerRuntimeException;
8
9
final class CallbackFieldDenormalizer implements FieldDenormalizerInterface
10
{
11
    /**
12
     * @var callable
13
     */
14
    private $callback;
15
16
    /**
17
     * @param callable $callback
18
     */
19 1
    public function __construct(callable $callback)
20
    {
21 1
        $this->callback = $callback;
22 1
    }
23
24
    /**
25
     * @param string                       $path
26
     * @param object                       $object
27
     * @param mixed                        $value
28
     * @param DenormalizerContextInterface $context
29
     * @param DenormalizerInterface|null   $denormalizer
30
     *
31
     * @throws DeserializerRuntimeException
32
     */
33 1
    public function denormalizeField(
34
        string $path,
35
        $object,
36
        $value,
37
        DenormalizerContextInterface $context,
38
        DenormalizerInterface $denormalizer = null
39
    ) {
40 1
        $callback = $this->callback;
41
42 1
        $callback($path, $object, $value, $context, $denormalizer);
43 1
    }
44
}
45