Completed
Push — master ( 751154...66b80e )
by Maxim
02:42
created

Lead::setAmoName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace mb24dev\AmoCRM\Entity;
4
5
/**
6
 * Class Lead
7
 *
8
 * @package mb24dev\AmoCRM\Entity
9
 */
10
class Lead implements AmoEntityInterface, AmoIdentityInterface
11
{
12
    private $id;
13
    private $name;
14
    private $statusID;
15
    private $pipelineID;
16
    private $price;
17
    private $responsibleUserID;
18
    private $requestID;
19
    private $customFields;
20
    private $tags;
21
    private $visitorUID;
22
23
    /**
24
     * @var \DateTime
25
     */
26
    private $dateCreate;
27
28
    /**
29
     * @var \DateTime
30
     */
31
    private $last_modified;
32
33
    /**
34
     * Lead constructor.
35
     *
36
     * @param $name
37
     * @param $statusID
38
     */
39
    public function __construct($name, $statusID)
40
    {
41
        $this->name = $name;
42
        $this->statusID = $statusID;
43
    }
44
45
    /**
46
     * @param mixed $id
47
     */
48
    public function setAmoId($id)
49
    {
50
        $this->id = $id;
51
    }
52
    /**
53
     * @param mixed $name
54
     */
55
    public function setAmoName($name)
56
    {
57
        $this->name = $name;
58
    }
59
    /**
60
     * @param \DateTime $dateCreate
61
     */
62
    public function setAmoDateCreate(\DateTime $dateCreate)
63
    {
64
        $this->dateCreate = $dateCreate;
65
    }
66
    /**
67
     * @param \DateTime $last_modified
68
     */
69
    public function setAmoLastModified(\DateTime $last_modified)
70
    {
71
        $this->last_modified = $last_modified;
72
    }
73
    /**
74
     * @param mixed $statusID
75
     */
76
    public function setAmoStatusID($statusID)
77
    {
78
        $this->statusID = $statusID;
79
    }
80
    /**
81
     * @param mixed $pipelineID
82
     */
83
    public function setAmoPipelineID($pipelineID)
84
    {
85
        $this->pipelineID = $pipelineID;
86
    }
87
    /**
88
     * @param mixed $price
89
     */
90
    public function setAmoPrice($price)
91
    {
92
        $this->price = $price;
93
    }
94
    /**
95
     * @param mixed $responsibleUserID
96
     */
97
    public function setAmoResponsibleUserID($responsibleUserID)
98
    {
99
        $this->responsibleUserID = $responsibleUserID;
100
    }
101
    /**
102
     * @param mixed $requestID
103
     */
104
    public function setAmoRequestID($requestID)
105
    {
106
        $this->requestID = $requestID;
107
    }
108
    /**
109
     * @param mixed $customFields
110
     */
111
    public function setAmoCustomFields($customFields)
112
    {
113
        $this->customFields = $customFields;
114
    }
115
    /**
116
     * @param mixed $tags
117
     */
118
    public function setAmoTags($tags)
119
    {
120
        $this->tags = $tags;
121
    }
122
    /**
123
     * @param mixed $visitorUID
124
     */
125
    public function setAmoVisitorUID($visitorUID)
126
    {
127
        $this->visitorUID = $visitorUID;
128
    }
129
130
    /**
131
     * @return array
132
     */
133
    public function toAmoArray()
134
    {
135
        return [
136
            'id' => $this->id,
137
            'name' => $this->name,
138
            'date_create' => $this->dateCreate ? $this->dateCreate->getTimestamp() : null,
139
            'last_modified' => $this->dateCreate ? $this->dateCreate->getTimestamp() : null,
140
            'status_id' => $this->statusID,
141
            'pipeline_id' => $this->pipelineID,
142
            'price' => $this->price,
143
            'responsible_user_id' => $this->responsibleUserID,
144
            'request_id' => $this->requestID,
145
            'custom_fields' => array_map(
146
                function (AmoEntityInterface $customField) {
147
                    return $customField->toAmoArray();
148
                },
149
                $this->customFields
150
            ),
151
            'tags' => $this->tags,
152
            'visitor_uid' => $this->visitorUID,
153
        ];
154
    }
155
156
    /**
157
     * @return mixed
158
     */
159
    public function getAmoID()
160
    {
161
        return $this->id;
162
    }
163
164
}
165