x Sorry, these patches are not available anymore due to data migration. Please run a fresh inspection.
Completed
Push — master ( 689800...fe66cd )
by Konstantin
01:50
created

Lead   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addCustomField() 0 4 1
A get() 0 15 3
A set() 0 4 1
1
<?php
2
3
namespace linkprofit\AmoCRM\entities;
4
5
use linkprofit\AmoCRM\traits\FieldsTrait;
6
7
/**
8
 * Class Lead
9
 * @package linkprofit\AmoCRM\entities
10
 */
11
class Lead implements EntityInterface
12
{
13
    public $id;
14
    public $name;
15
    public $created_at;
16
    public $updated_at;
17
    public $status_id;
18
    public $pipeline_id;
19
    public $responsible_user_id;
20
    public $sale;
21
    public $tags;
22
    public $contacts_id;
23
    public $company_id;
24
    public $custom_fields = [];
25
    public $price;
26
27
    protected $fieldList = [
28
        'id', 'name', 'created_at', 'updated_at',
29
        'status_id', 'pipeline_id', 'responsible_user_id',
30
        'sale', 'tags', 'contacts_id', 'company_id', 'price'
31
    ];
32
33
    use FieldsTrait;
34
35
    /**
36
     * @param CustomField $field
37
     */
38 4
    public function addCustomField(CustomField $field)
39
    {
40 4
        $this->custom_fields[] = $field;
41 4
    }
42
43
    /**
44
     * @return array
45
     */
46 5
    public function get()
47
    {
48 5
        $custom_fields = [];
49 5
        foreach ($this->custom_fields as $custom_field) {
50 4
            $custom_fields[] = $custom_field->get();
51 5
        }
52
53 5
        $fields = $this->getExistedValues($this->fieldList);
54
55 5
        if (count($custom_fields)) {
56 4
            $fields['custom_fields'] = $custom_fields;
57 4
        }
58
59 5
        return $fields;
60
    }
61
62
    /**
63
     * @param $array
64
     */
65 2
    public function set($array)
66
    {
67 2
        $this->setFromArray($this->fieldList, $array);
68
    }
69
}