SerializerProcessor::updateEntity()   A
last analyzed

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($data, get_class($entity), null, ['object_to_populate' => $entity]);
27
    }
28
}
29