1 | <?php |
||
21 | class Result |
||
22 | { |
||
23 | /** |
||
24 | * @var Phone |
||
25 | */ |
||
26 | private $phone; |
||
27 | |||
28 | /** |
||
29 | * @var bool |
||
30 | */ |
||
31 | private $status; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $messageId; |
||
37 | |||
38 | /** |
||
39 | * @var Error |
||
40 | */ |
||
41 | private $error; |
||
42 | |||
43 | /** |
||
44 | * Constructor. |
||
45 | * |
||
46 | * @param Phone $phone |
||
47 | * @param bool $status |
||
48 | * @param string $messageId |
||
49 | * @param Error $error |
||
50 | */ |
||
51 | 7 | public function __construct(Phone $phone, bool $status, string $messageId = null, Error $error = null) |
|
58 | |||
59 | /** |
||
60 | * Create successfully result |
||
61 | * |
||
62 | * @param Phone $phone |
||
63 | * @param string $messageId |
||
64 | * |
||
65 | * @return Result |
||
66 | */ |
||
67 | 6 | public static function successfully(Phone $phone, string $messageId = null): Result |
|
71 | |||
72 | /** |
||
73 | * Create failed result |
||
74 | * |
||
75 | * @param Phone $phone |
||
76 | * @param Error $error |
||
77 | * @param string $messageId |
||
78 | * |
||
79 | * @return Result |
||
80 | */ |
||
81 | 4 | public static function failed(Phone $phone, Error $error, string $messageId = null): Result |
|
85 | |||
86 | /** |
||
87 | * Is success send SMS? |
||
88 | * |
||
89 | * @return bool |
||
90 | */ |
||
91 | 4 | public function isSuccessfully(): bool |
|
95 | |||
96 | /** |
||
97 | * Is failure send SMS? |
||
98 | * |
||
99 | * @return bool |
||
100 | */ |
||
101 | 4 | public function isFailed(): bool |
|
105 | |||
106 | /** |
||
107 | * Get the phone |
||
108 | * |
||
109 | * @return Phone |
||
110 | */ |
||
111 | 5 | public function getPhone(): Phone |
|
115 | |||
116 | /** |
||
117 | * Get the identifier of message |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | 3 | public function getMessageId(): ?string |
|
125 | |||
126 | /** |
||
127 | * Get the reason of error |
||
128 | * |
||
129 | * @return Error |
||
130 | */ |
||
131 | 3 | public function getError(): ?Error |
|
135 | } |
||
136 |