Completed
Branch v2.0.0 (e47d62)
by Alexander
03:40
created

DomainClientService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 14
loc 14
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A toJsonObject() 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
namespace Core\Domain;
4
5
use Phalcon\Di\AbstractInjectionAware;
6
use Symfony\Component\Serializer\Encoder\JsonEncoder;
7
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
8
use Symfony\Component\Serializer\Serializer;
9
10 View Code Duplication
class DomainClientService extends AbstractInjectionAware
11
{
12
    public function __construct($di)
13
    {
14
        $this->setDI($di);
15
    }
16
17
    protected function toJsonObject($object)
18
    {
19
        $serializer = new Serializer([new ObjectNormalizer()], [new JsonEncoder()]);
20
21
        return json_decode($serializer->serialize($object, 'json'));
22
    }
23
}
24