Completed
Push — master ( 06e52a...98c39c )
by Pavel
13:39 queued 10:37
created

JmsSerializerProcessor::__construct()   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 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Adaptors\JmsSerializer;
4
5
use JMS\Serializer\ArrayTransformerInterface as JmsDenormalizerInterface;
6
use ScayTrase\Api\Cruds\EntityProcessorInterface;
7
8
final class JmsSerializerProcessor implements EntityProcessorInterface
9
{
10
    /** @var JmsDenormalizerInterface */
11
    private $denormalizer;
12
13
    /**
14
     * JmsSerializerProcessor constructor.
15
     *
16
     * @param JmsDenormalizerInterface $denormailzer
17
     */
18
    public function __construct(JmsDenormalizerInterface $denormailzer)
19
    {
20
        $this->denormalizer = $denormailzer;
21
    }
22
23
    /** {@inheritdoc} */
24
    public function updateEntity($entity, $data)
25
    {
26
        $this->denormalizer->fromArray(
27
            $data,
28
            get_class($entity),
29
            JmsContextFactory::deserialization(['object_to_populate' => $entity])
30
        );
31
32
        return $entity;
33
    }
34
}
35