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

JmsSerializerProcessor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 27
ccs 0
cts 13
cp 0
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
    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