PipelineService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 2
cbo 3
dl 37
loc 37
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A parseArrayToEntity() 7 7 1
A getLink() 4 4 1
A add() 6 6 2

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 linkprofit\AmoCRM\services;
4
5
use linkprofit\AmoCRM\entities\EntityInterface;
6
use linkprofit\AmoCRM\entities\Pipeline;
7
use linkprofit\AmoCRM\RequestHandler;
8
9
/**
10
 * Class PipelineService
11
 * @package linkprofit\AmoCRM\services
12
 */
13 View Code Duplication
class PipelineService extends BaseService
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /**
16
     * @var Pipeline[]
17
     */
18
    protected $entities = [];
19
20
    /**
21
     * @param Pipeline $pipeline
22
     */
23 4
    public function add(EntityInterface $pipeline)
24
    {
25 4
        if ($pipeline instanceof Pipeline) {
26 4
            $this->entities[] = $pipeline;
27 4
        }
28 4
    }
29
30
    /**
31
     * @param $array
32
     * @return Pipeline
33
     */
34 4
    public function parseArrayToEntity($array)
35
    {
36 4
        $pipeline = new Pipeline();
37 4
        $pipeline->set($array);
38
39 4
        return $pipeline;
40
    }
41
42
    /**
43
     * @return string
44
     */
45 4
    protected function getLink()
46
    {
47 4
        return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/private/api/v2/json/pipelines/set';
48
    }
49
}