Completed
Push — master ( 533e78...e97401 )
by Janusz
02:11
created

SmsOut   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 197
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 14
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 197
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 31 2
A createFromResponseArray() 0 15 2
A getId() 0 4 1
A getDeliveryTime() 0 4 1
A getCount() 0 4 1
A getPrice() 0 4 1
A getContent() 0 4 1
A getNumberTo() 0 4 1
A getIncomingTime() 0 4 1
A getStatus() 0 4 1
A getStatusD() 0 4 1
A getNumberFrom() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Ittoolspl\Smslabs\VO;
5
6
class SmsOut
7
{
8
    /**
9
     * @var string
10
     */
11
    private $id;
12
13
    /**
14
     * @var \DateTime
15
     */
16
    private $deliveryTime;
17
18
    /**
19
     * @var int
20
     */
21
    private $count;
22
23
    /**
24
     * @var float
25
     */
26
    private $price;
27
28
    /**
29
     * @var string
30
     */
31
    private $content;
32
33
    /**
34
     * @var string
35
     */
36
    private $numberTo;
37
38
    /**
39
     * @var \DateTime
40
     */
41
    private $incomingTime;
42
43
    /**
44
     * @var int
45
     */
46
    private $status;
47
48
    /**
49
     * @var string
50
     */
51
    private $statusD;
52
53
    /**
54
     * @var string
55
     */
56
    private $numberFrom;
57
58
    /**
59
     * SmsOut constructor.
60
     * @param string $id
61
     * @param int $deliveryTime
62
     * @param int $count
63
     * @param float $price
64
     * @param string $content
65
     * @param string $numberTo
66
     * @param int $incomingTime
67
     * @param int $status
68
     * @param string $statusD
69
     * @param string $numberFrom
70
     */
71
    public function __construct(
72
        string $id,
73
        int $deliveryTime,
74
        int $count,
75
        float $price,
76
        string $content,
77
        string $numberTo,
78
        int $incomingTime,
79
        int $status,
80
        string $statusD,
81
        string $numberFrom
82
    ) {
83
        if ($deliveryTime !== null) {
84
            $deliveryTimeDT = new \DateTime();
85
            $deliveryTimeDT->setTimestamp($deliveryTime);
86
            $this->deliveryTime = $deliveryTimeDT;
87
        }
88
89
        $incomingTimeDT = new \DateTime();
90
        $incomingTimeDT->setTimestamp($incomingTime);
91
        $this->incomingTime = $incomingTimeDT;
92
93
        $this->id         = $id;
94
        $this->count      = $count;
95
        $this->price      = $price;
96
        $this->content    = $content;
97
        $this->numberTo   = $numberTo;
98
        $this->status     = $status;
99
        $this->statusD    = $statusD;
100
        $this->numberFrom = $numberFrom;
101
    }
102
103
    /**
104
     * @param array $response
105
     * @return SmsOut
106
     */
107
    public static function createFromResponseArray(array $response) : SmsOut
108
    {
109
        return new self(
110
            $response['_id'],
111
            array_key_exists('del_t', $response) ? $response['del_t'] : 0,
112
            $response['s_cnt'],
113
            $response['price'],
114
            $response['s_con'],
115
            $response['no_to'],
116
            $response['in_t'],
117
            $response['stat'],
118
            $response['stat_d'],
119
            $response['no_fr']
120
        );
121
    }
122
123
    /**
124
     * @return string
125
     */
126
    public function getId() : string
127
    {
128
        return $this->id;
129
    }
130
131
    /**
132
     * @return \DateTime
133
     */
134
    public function getDeliveryTime() : \DateTime
135
    {
136
        return $this->deliveryTime;
137
    }
138
139
    /**
140
     * @return int
141
     */
142
    public function getCount() : int
143
    {
144
        return $this->count;
145
    }
146
147
    /**
148
     * @return float
149
     */
150
    public function getPrice() : float
151
    {
152
        return $this->price;
153
    }
154
155
    /**
156
     * @return string
157
     */
158
    public function getContent() : string
159
    {
160
        return $this->content;
161
    }
162
163
    /**
164
     * @return string
165
     */
166
    public function getNumberTo() : string
167
    {
168
        return $this->numberTo;
169
    }
170
171
    /**
172
     * @return \DateTime
173
     */
174
    public function getIncomingTime() : \DateTime
175
    {
176
        return $this->incomingTime;
177
    }
178
179
    /**
180
     * @return int
181
     */
182
    public function getStatus() : int
183
    {
184
        return $this->status;
185
    }
186
187
    /**
188
     * @return string
189
     */
190
    public function getStatusD() : string
191
    {
192
        return $this->statusD;
193
    }
194
195
    /**
196
     * @return string
197
     */
198
    public function getNumberFrom() : string
199
    {
200
        return $this->numberFrom;
201
    }
202
}
203