Completed
Pull Request — dev (#13)
by Konstantin
02:01
created

LinkElementCapableEntity   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 28
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A linkElement() 0 10 2
1
<?php
2
3
namespace linkprofit\AmoCRM\entities;
4
5
use function get_called_class;
6
use function var_dump;
7
8
/**
9
 * Class LinkElementCapableEntity
10
 * @package linkprofit\AmoCRM\entities
11
 */
12
abstract class LinkElementCapableEntity extends BaseEntity
13
{
14
    /**
15
     * @var int Уникальный идентификатор контакта или сделки (сделка или контакт указывается в element_type)
16
     */
17
    public $element_id;
18
19
    /**
20
     * @var int Тип привязываемого элемента (1 - контакт, 2- сделка, 3 - компания, 12 - покупатель)
21
     */
22
    public $element_type;
23
24
    /**
25
     * @param LinkableElement $element
26
     *
27
     * @return bool
28
     */
29 8
    public function linkElement(LinkableElement $element)
30
    {
31 8
        if (!$element->supports(get_called_class())) {
32 3
            return false;
33
        }
34
35 5
        $element->linkSelf($this);
36
37 5
        return true;
38
    }
39
}