Completed
Push — master ( c00bbf...06e52a )
by Pavel
17:08 queued 22s
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 JMS\Serializer\Serializer;
7
use ScayTrase\Api\Cruds\EntityProcessorInterface;
8
9
final class JmsSerializerProcessor implements EntityProcessorInterface
10
{
11
    /** @var JmsDenormalizerInterface */
12
    private $denormalizer;
13
14
    /**
15
     * JmsSerializerProcessor constructor.
16
     *
17
     * @param JmsDenormalizerInterface $denormailzer
18
     */
19 2
    public function __construct(JmsDenormalizerInterface $denormailzer)
20
    {
21 2
        $this->denormalizer = $denormailzer;
22 2
    }
23
24
    /** {@inheritdoc} */
25 2
    public function updateEntity($entity, $data)
26
    {
27 2
        $newObject =$this->denormalizer->fromArray(
0 ignored issues
show
Unused Code introduced by
$newObject is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
28 2
            $data,
29 2
            get_class($entity),
30 2
            JmsContextFactory::deserialization(['object_to_populate' => $entity])
31
        );
32
33 2
        return $entity;
34
    }
35
}
36