Record   A
last analyzed

Complexity

Total Complexity 28

Size/Duplication

Total Lines 280
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 28
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 280
rs 10

26 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getNumber() 0 4 1
A setNumber() 0 4 1
A getMessage() 0 4 1
A setMessage() 0 4 1
A getTransactionId() 0 4 1
A setTransactionId() 0 4 1
A getState() 0 4 1
A setState() 0 4 1
A getDuration() 0 4 1
A setDuration() 0 4 1
A isResponded() 0 4 1
A setResponded() 0 4 1
A getPrice() 0 4 1
A setPrice() 0 4 1
A getCurrency() 0 4 1
A setCurrency() 0 4 1
A getResponder() 0 4 1
A setResponder() 0 4 1
A getRespondedAt() 0 4 1
A setRespondedAt() 0 4 1
A getProvider() 0 4 1
A setProvider() 0 4 1
A getUser() 0 4 1
A setUser() 0 4 1
A responded() 0 7 3
1
<?php
2
3
namespace DoS\SMSBundle\Model;
4
5
use libphonenumber\PhoneNumber;
6
use Sylius\Component\User\Model\UserInterface;
7
8
class Record implements RecordInterface
9
{
10
    use TimestampTrait;
11
12
    /**
13
     * @var int
14
     */
15
    protected $id;
16
17
    /**
18
     * @var PhoneNumber
19
     */
20
    protected $number;
21
22
    /**
23
     * @var string;
24
     */
25
    protected $message;
26
27
    /**
28
     * @var string;
29
     */
30
    protected $transactionId;
31
32
    /**
33
     * @var string
34
     */
35
    protected $state = self::STATE_DRAFT;
36
37
    /**
38
     * @var float
39
     */
40
    protected $duration = 0;
41
42
    /**
43
     * @var float
44
     */
45
    protected $price = 0;
46
47
    /**
48
     * @var string
49
     */
50
    protected $currency = 'THB';
51
52
    /**
53
     * @var bool
54
     */
55
    protected $responded = false;
56
57
    /**
58
     * @var array
59
     */
60
    protected $responder = array();
61
62
    /**
63
     * @var \DateTime
64
     */
65
    protected $respondedAt;
66
67
    /**
68
     * @var ProviderInterface
69
     */
70
    protected $provider;
71
72
    /**
73
     * @var UserInterface
74
     */
75
    protected $user;
76
77
    /**
78
     * @return int
79
     */
80
    public function getId()
81
    {
82
        return $this->id;
83
    }
84
85
    /**
86
     * @return PhoneNumber
87
     */
88
    public function getNumber()
89
    {
90
        return $this->number;
91
    }
92
93
    /**
94
     * @param PhoneNumber $number
95
     */
96
    public function setNumber($number)
97
    {
98
        $this->number = $number;
99
    }
100
101
    /**
102
     * @return string
103
     */
104
    public function getMessage()
105
    {
106
        return $this->message;
107
    }
108
109
    /**
110
     * @param string $message
111
     */
112
    public function setMessage($message)
113
    {
114
        $this->message = $message;
115
    }
116
117
    /**
118
     * @return string
119
     */
120
    public function getTransactionId()
121
    {
122
        return $this->transactionId;
123
    }
124
125
    /**
126
     * @param string $transactionId
127
     */
128
    public function setTransactionId($transactionId)
129
    {
130
        $this->transactionId = $transactionId;
131
    }
132
133
    /**
134
     * @return string
135
     */
136
    public function getState()
137
    {
138
        return $this->state;
139
    }
140
141
    /**
142
     * @param string $state
143
     */
144
    public function setState($state)
145
    {
146
        $this->state = $state;
147
    }
148
149
    /**
150
     * @return float
151
     */
152
    public function getDuration()
153
    {
154
        return $this->duration;
155
    }
156
157
    /**
158
     * @param float $duration
159
     */
160
    public function setDuration($duration)
161
    {
162
        $this->duration = $duration;
163
    }
164
165
    /**
166
     * @return bool
167
     */
168
    public function isResponded()
169
    {
170
        return $this->responded;
171
    }
172
173
    /**
174
     * @param bool $responded
175
     */
176
    public function setResponded($responded)
177
    {
178
        $this->responded = $responded;
179
    }
180
181
    /**
182
     * @return float
183
     */
184
    public function getPrice()
185
    {
186
        return $this->price;
187
    }
188
189
    /**
190
     * @param float $price
191
     */
192
    public function setPrice($price)
193
    {
194
        $this->price = $price;
195
    }
196
197
    /**
198
     * @return string
199
     */
200
    public function getCurrency()
201
    {
202
        return $this->currency;
203
    }
204
205
    /**
206
     * @param string $currency
207
     */
208
    public function setCurrency($currency)
209
    {
210
        $this->currency = $currency;
211
    }
212
213
    /**
214
     * @return array
215
     */
216
    public function getResponder()
217
    {
218
        return $this->responder;
219
    }
220
221
    /**
222
     * @param array $responder
223
     */
224
    public function setResponder(array $responder)
225
    {
226
        $this->responder = $responder;
227
    }
228
229
    /**
230
     * @return \DateTime
231
     */
232
    public function getRespondedAt()
233
    {
234
        return $this->respondedAt;
235
    }
236
237
    /**
238
     * @param \DateTime $respondedAt
239
     */
240
    public function setRespondedAt($respondedAt)
241
    {
242
        $this->respondedAt = $respondedAt;
243
    }
244
245
    /**
246
     * @return ProviderInterface
247
     */
248
    public function getProvider()
249
    {
250
        return $this->provider;
251
    }
252
253
    /**
254
     * @param ProviderInterface $provider
255
     */
256
    public function setProvider(ProviderInterface $provider)
257
    {
258
        $this->provider = $provider;
259
    }
260
261
    /**
262
     * {@inheritdoc}
263
     */
264
    public function getUser()
265
    {
266
        return $this->user;
267
    }
268
269
    /**
270
     * {@inheritdoc}
271
     */
272
    public function setUser(UserInterface $user = null)
273
    {
274
        $this->user = $user;
275
    }
276
277
    /**
278
     * {@inheritdoc}
279
     */
280
    public function responded(array $data, $success, \DateTime $dateTime = null)
281
    {
282
        $this->responder = $data;
283
        $this->responded = true;
284
        $this->respondedAt = $dateTime ?: new \DateTime();
285
        $this->state = $success ? self::STATE_DELIVERED : self::STATE_FAILED;
286
    }
287
}
288