Completed
Branch v2.0.0 (f654ea)
by Alexander
01:15
created

PresenterEntity   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 9
loc 9
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @author Alexander Torosh <[email protected]>
4
 */
5
6
namespace Core\Domain;
7
8
use JsonSerializable;
9
use Symfony\Component\Serializer\Encoder\JsonEncoder;
10
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
11
use Symfony\Component\Serializer\Serializer;
12
13 View Code Duplication
class PresenterEntity implements JsonSerializable
14
{
15
    public function jsonSerialize()
16
    {
17
        $serializer = new Serializer([new ObjectNormalizer()], [new JsonEncoder()]);
18
19
        return json_decode($serializer->serialize($this, 'json'));
20
    }
21
}
22