TaskService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

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\Task;
7
8
/**
9
 * Class TaskService
10
 * @package linkprofit\AmoCRM\services
11
 */
12 View Code Duplication
class TaskService 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...
13
{
14
    /**
15
     * @var Task[]
16
     */
17
    protected $entities = [];
18
19
    /**
20
     * @param Task $task
21
     */
22 3
    public function add(EntityInterface $task)
23
    {
24 3
        if ($task instanceof Task) {
25 3
            $this->entities[] = $task;
26 3
        }
27 3
    }
28
29
    /**
30
     * @param $array
31
     * @return Task
32
     */
33 3
    public function parseArrayToEntity($array)
34
    {
35 3
        $task = new Task();
36 3
        $task->set($array);
37
38 3
        return $task;
39
    }
40
41
    /**
42
     * @return string
43
     */
44 3
    protected function getLink()
45
    {
46 3
        return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/api/v2/tasks';
47
    }
48
49
}