Completed
Push — master ( e93435...670f0c )
by Pavel
09:43
created

SerializerProcessor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 21
ccs 0
cts 8
cp 0
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A updateEntity() 0 4 1
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Adaptors\Symfony;
4
5
use ScayTrase\Api\Cruds\EntityProcessorInterface;
6
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
7
8
final class SerializerProcessor implements EntityProcessorInterface
9
{
10
    /** @var  DenormalizerInterface */
11
    private $denormalizer;
12
13
    /**
14
     * SerializerProcessor constructor.
15
     *
16
     * @param DenormalizerInterface $denormalizer
17
     */
18
    public function __construct(DenormalizerInterface $denormalizer)
19
    {
20
        $this->denormalizer = $denormalizer;
21
    }
22
23
    /** {@inheritdoc} */
24
    public function updateEntity($entity, $data)
25
    {
26
        return $this->denormalizer->denormalize($this, get_class($entity), ['object_to_populate' => $entity]);
0 ignored issues
show
Documentation introduced by
array('object_to_populate' => $entity) is of type array<string,object,{"ob...to_populate":"object"}>, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
    }
28
}
29