Completed
Push — dev ( 13f91a...4a164e )
by Konstantin
02:18
created

Lead::supports()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 6
loc 6
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace linkprofit\AmoCRM\entities;
4
5
use linkprofit\AmoCRM\traits\CompanyLinkable;
6
use linkprofit\AmoCRM\traits\ContactsLinkable;
7
8
/**
9
 * Class Lead
10
 * @package linkprofit\AmoCRM\entities
11
 */
12 View Code Duplication
class Lead extends CustomizableEntity implements LinkableElement
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
     * Сделка
16
     */
17
    const ELEMENT_TYPE = 2;
18
19
    /**
20
     * @var string Название сделки
21
     */
22
    public $name;
23
24
    /**
25
     * @var integer Статус сделки (id этапа продаж см. Воронки и этапы продаж) Чтобы перенести сделку в другую воронку, необходимо установить ей статус из нужной воронки
26
     */
27
    public $status_id;
28
29
    /**
30
     * @var integer ID воронки. Указывается в том случае, если выбраны статусы id 142 или 143, т.к. эти статусы не уникальны и обязательны для всех цифровых воронок.
31
     */
32
    public $pipeline_id;
33
34
    /**
35
     * @var integer Бюджет сделки
36
     */
37
    public $sale;
38
39
    /**
40
     * @var string Если вы хотите задать новые теги, перечислите их внутри строковой переменной через запятую
41
     */
42
    public $tags;
43
44
    /**
45
     * @var int Id пользователя изменившего сущность, если 0, то робот
46
     */
47
    public $modified_user_id;
48
49
    /**
50
     * @var array
51
     */
52
    protected $fieldList = [
53
        'id', 'name', 'created_at', 'updated_at',
54
        'status_id', 'pipeline_id', 'responsible_user_id',
55
        'sale', 'tags', 'contacts_id', 'company_id',
56
        'modified_user_id'
57
    ];
58
59
    use CompanyLinkable,
60
        ContactsLinkable;
61
62
    /**
63
     * @param $entityClass
64
     *
65
     * @return bool
66
     */
67 4
    public function supports($entityClass)
68
    {
69 4
        $supportedClasses = [Task::class, Note::class];
70
71 4
        return in_array($entityClass, $supportedClasses, 1) && !empty($this->id);
72
    }
73
74
    /**
75
     * @param LinkElementCapableEntity $entity
76
     *
77
     * @return LinkElementCapableEntity
78
     */
79 2
    public function linkSelf(LinkElementCapableEntity $entity)
80
    {
81 2
        $entity->element_type = self::ELEMENT_TYPE;
82 2
        $entity->element_id = $this->id;
83
84 2
        return $entity;
85
    }
86
}