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

JmsSerializerProcessor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 69.23%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 27
ccs 9
cts 13
cp 0.6923
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A updateEntity() 0 10 1
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