Completed
Push — master ( 1565b3...a35685 )
by Konstantin
03:55 queued 01:55
created

Status   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 56
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 13 4
1
<?php
2
3
namespace linkprofit\AmoCRM\entities;
4
5
use linkprofit\AmoCRM\traits\FieldList;
6
7
/**
8
 * Class Status
9
 * @package linkprofit\AmoCRM\entities
10
 */
11
class Status implements EntityInterface
12
{
13
    /**
14
     * Статус Успешно
15
     */
16
    const SUCCESS = 142;
17
18
    /**
19
     * Статус Провалено
20
     */
21
    const FAILED = 143;
22
23
    /**
24
     * @var integer Уникальный идентификатор этапа
25
     */
26
    public $id;
27
28
    /**
29
     * @var string Название этапа
30
     */
31
    public $name;
32
33
    /**
34
     * @var int Порядковый номер этапа при отображении (автоматически пересчитывается после добавления)
35
     */
36
    public $sort;
37
38
    /**
39
     * @var string Цвет этапа (подробнее можно узнать здесь)
40
     */
41
    public $color;
42
43
    /**
44
     * @var array
45
     */
46
    protected $fieldList = ['name', 'sort', 'color'];
47
48
    use FieldList;
49
50
    /**
51
     * @return array
52
     */
53 7
    public function get()
54
    {
55 7
        if (in_array($this->id, [Status::SUCCESS, Status::FAILED]) && $this->name) {
56 1
            return [$this->id => ['name' => $this->name]];
57
        }
58 6
        $values = $this->getExistedValues($this->fieldList);
59
60 6
        if ($this->id) {
61 1
            return [$this->id => $values];
62
        }
63
64 5
        return $values;
65
    }
66
}