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

SerializerProcessor::updateEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 2
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