Completed
Push — dev ( 4a164e...157791 )
by Konstantin
02:03
created

TaskService::composeListLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace linkprofit\AmoCRM\services;
4
5
use linkprofit\AmoCRM\entities\EntityInterface;
6
use linkprofit\AmoCRM\entities\Task;
7
use linkprofit\AmoCRM\traits\IdentifiableList;
8
use linkprofit\AmoCRM\traits\PaginableList;
9
10
/**
11
 * Class TaskService
12
 * @package linkprofit\AmoCRM\services
13
 */
14 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...
15
{
16
    use IdentifiableList,
17
        PaginableList;
18
19
    /**
20
     * @var Task[]
21
     */
22
    protected $entities = [];
23
24
    /**
25
     * @param Task $task
26
     */
27 3
    public function add(EntityInterface $task)
28
    {
29 3
        if ($task instanceof Task) {
30 3
            $this->entities[] = $task;
31
        }
32 3
    }
33
34
    /**
35
     * @param $link
36
     *
37
     * @return string
38
     */
39
    protected function composeListLink($link)
40
    {
41
        $query = $this->addIdToQuery();
42
43
        $link .= '?' . http_build_query($query);
44
45
        return $link;
46
    }
47
48
    /**
49
     * @param $array
50
     * @return Task
51
     */
52 3
    public function parseArrayToEntity($array)
53
    {
54 3
        $task = new Task();
55 3
        $task->set($array);
56
57 3
        return $task;
58
    }
59
60
    /**
61
     * @return string
62
     */
63 3
    protected function getLink()
64
    {
65 3
        return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/api/v2/tasks';
66
    }
67
68
}