1 | <?php |
||
15 | class Result implements \JsonSerializable |
||
16 | { |
||
17 | const STATUS_SUCCESS = 'success'; |
||
18 | const STATUS_ERROR = 'error'; |
||
19 | |||
20 | /** |
||
21 | * Device token. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $token; |
||
26 | |||
27 | /** |
||
28 | * Result time. |
||
29 | * |
||
30 | * @var \DateTime |
||
31 | */ |
||
32 | protected $date; |
||
33 | |||
34 | /** |
||
35 | * Result status. |
||
36 | * |
||
37 | * @var int |
||
38 | */ |
||
39 | protected $status; |
||
40 | |||
41 | /** |
||
42 | * Result status message. |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $statusMessage; |
||
47 | |||
48 | /** |
||
49 | * @param string $token |
||
50 | * @param int|\DateTime|null $date |
||
51 | * @param string $status |
||
52 | * @param string|null $statusMessage |
||
53 | * |
||
54 | * @throws \InvalidArgumentException |
||
55 | */ |
||
56 | public function __construct( |
||
79 | |||
80 | /** |
||
81 | * Retrieve result device token. |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getToken() |
||
89 | |||
90 | /** |
||
91 | * Set result device token. |
||
92 | * |
||
93 | * @param string $token |
||
94 | * |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function setToken($token) |
||
103 | |||
104 | /** |
||
105 | * Retrieve result time. |
||
106 | * |
||
107 | * @return \DateTime |
||
108 | */ |
||
109 | public function getDate() |
||
113 | |||
114 | /** |
||
115 | * Set result time. |
||
116 | * |
||
117 | * @param \DateTime $date |
||
118 | * |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function setDate(\DateTime $date) |
||
127 | |||
128 | /** |
||
129 | * Retrieve result status. |
||
130 | * |
||
131 | * @return int |
||
132 | */ |
||
133 | public function getStatus() |
||
137 | |||
138 | /** |
||
139 | * Check successful status. |
||
140 | * |
||
141 | * @return bool |
||
142 | */ |
||
143 | public function isSuccess() |
||
147 | |||
148 | /** |
||
149 | * Check error status. |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | public function isError() |
||
157 | |||
158 | /** |
||
159 | * Set result status. |
||
160 | * |
||
161 | * @param string $status |
||
162 | * |
||
163 | * @throws \InvalidArgumentException |
||
164 | * |
||
165 | * @return $this |
||
166 | */ |
||
167 | public function setStatus($status) |
||
177 | |||
178 | /** |
||
179 | * Retrieve result status message. |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | public function getStatusMessage() |
||
187 | |||
188 | /** |
||
189 | * Check successful status message. |
||
190 | * |
||
191 | * @param string|null $statusMessage |
||
192 | * |
||
193 | * @return $this |
||
194 | */ |
||
195 | public function setStatusMessage($statusMessage = null) |
||
201 | |||
202 | /** |
||
203 | * {@inheritdoc} |
||
204 | * |
||
205 | * @return array |
||
206 | */ |
||
207 | public function jsonSerialize() |
||
216 | } |
||
217 |