Completed
Push — master ( bdc52c...616bc8 )
by Konstantin
03:41
created

TaskService::add()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 6
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 3
nc 2
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
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 array Lead
16
     */
17
    protected $entities = [];
18
19
    /**
20
     * @param Task $task
21
     */
22 2
    public function add(EntityInterface $task)
23
    {
24 2
        if ($task instanceof Task) {
25 2
            $this->entities[] = $task;
26 2
        }
27 2
    }
28
29
    /**
30
     * @param $array
31
     * @return Task
32
     */
33 2
    public function parseArrayToEntity($array)
34
    {
35 2
        $task = new Task();
36 2
        $task->set($array);
37
38 2
        return $task;
39
    }
40
41
    /**
42
     * @return string
43
     */
44 2
    protected function getLink()
45
    {
46 2
        return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/api/v2/tasks';
47
    }
48
49
}