Completed
Push — master ( 98c39c...c8155d )
by Pavel
16:50
created

JmsSerializerProcessor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1.0156
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 2
    public function __construct(JmsDenormalizerInterface $denormailzer)
19
    {
20 2
        $this->denormalizer = $denormailzer;
21 2
    }
22
23
    /** {@inheritdoc} */
24 2
    public function updateEntity($entity, $data)
25
    {
26 2
        $this->denormalizer->fromArray(
27 2
            $data,
28 2
            get_class($entity),
29 2
            JmsContextFactory::deserialization(['object_to_populate' => $entity])
30
        );
31
32 2
        return $entity;
33
    }
34
}
35