CustomizableEntity   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addCustomField() 0 4 1
A get() 0 19 4
1
<?php
2
3
namespace linkprofit\AmoCRM\entities;
4
5
/**
6
 * Class CustomizableEntity
7
 * @package linkprofit\AmoCRM\entities
8
 */
9
abstract class CustomizableEntity extends BaseEntity
10
{
11
    /**
12
     * @var CustomField[]
13
     */
14
    protected $custom_fields = [];
15
16
    /**
17
     * @param CustomField $field
18
     */
19 32
    public function addCustomField(CustomField $field)
20
    {
21 32
        $this->custom_fields[] = $field;
22 32
    }
23
24
    /**
25
     * @return array
26
     */
27 46
    public function get()
28
    {
29 46
        if ($this->id) {
30 12
            $this->setUpdatedTime();
31 12
        }
32
33 46
        $custom_fields = [];
34 46
        foreach ($this->custom_fields as $custom_field) {
35 27
            $custom_fields[] = $custom_field->get();
36 46
        }
37
38 46
        $fields = $this->getExistedValues($this->fieldList);
39
40 46
        if (count($custom_fields)) {
41 27
            $fields['custom_fields'] = $custom_fields;
42 27
        }
43
44 46
        return $fields;
45
    }
46
}