1 | <?php |
||
21 | abstract class AbstractNotification |
||
22 | { |
||
23 | use OptionsTrait; |
||
24 | |||
25 | const STATUS_PENDING = 0; |
||
26 | const STATUS_SENT = 1; |
||
27 | |||
28 | /** |
||
29 | * @var \Jgut\Tify\Service\AbstractService |
||
30 | */ |
||
31 | protected $service; |
||
32 | |||
33 | /** |
||
34 | * @var \Jgut\Tify\Message\AbstractMessage |
||
35 | */ |
||
36 | protected $message; |
||
37 | |||
38 | /** |
||
39 | * @var \Jgut\Tify\Recipient\AbstractRecipient[] |
||
40 | */ |
||
41 | protected $recipients = []; |
||
42 | |||
43 | /** |
||
44 | * @var int |
||
45 | */ |
||
46 | protected $status = self::STATUS_PENDING; |
||
47 | |||
48 | /** |
||
49 | * Notification resultss. |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $results = []; |
||
54 | |||
55 | /** |
||
56 | * @param \Jgut\Tify\Service\AbstractService $service |
||
57 | * @param \Jgut\Tify\Message\AbstractMessage $message |
||
58 | * @param \Jgut\Tify\Recipient\AbstractRecipient[] $recipients |
||
59 | * @param array $options |
||
60 | */ |
||
61 | public function __construct( |
||
76 | |||
77 | /** |
||
78 | * Get default notification options. |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | abstract protected function getDefaultOptions(); |
||
83 | |||
84 | /** |
||
85 | * Get service. |
||
86 | * |
||
87 | * @return \Jgut\Tify\Service\AbstractService |
||
88 | */ |
||
89 | final public function getService() |
||
93 | |||
94 | /** |
||
95 | * Set service. |
||
96 | * |
||
97 | * @param \Jgut\Tify\Service\AbstractService $service |
||
98 | */ |
||
99 | abstract public function setService(AbstractService $service); |
||
100 | |||
101 | /** |
||
102 | * Get message. |
||
103 | * |
||
104 | * @return \Jgut\Tify\Message\AbstractMessage |
||
105 | */ |
||
106 | final public function getMessage() |
||
110 | |||
111 | /** |
||
112 | * Set message. |
||
113 | * |
||
114 | * @param \Jgut\Tify\Message\AbstractMessage $message |
||
115 | */ |
||
116 | abstract public function setMessage(AbstractMessage $message); |
||
117 | |||
118 | /** |
||
119 | * Retrieve list of recipients. |
||
120 | * |
||
121 | * @return \Jgut\Tify\Recipient\AbstractRecipient[] |
||
122 | */ |
||
123 | final public function getRecipients() |
||
127 | |||
128 | /** |
||
129 | * Add recipient. |
||
130 | * |
||
131 | * @param \Jgut\Tify\Recipient\AbstractRecipient $recipient |
||
132 | */ |
||
133 | abstract public function addRecipient(AbstractRecipient $recipient); |
||
134 | |||
135 | /** |
||
136 | * Retrieve notification status. |
||
137 | * |
||
138 | * @return int |
||
139 | */ |
||
140 | final public function getStatus() |
||
144 | |||
145 | /** |
||
146 | * Check if notification status is sent. |
||
147 | * |
||
148 | * @return bool |
||
149 | */ |
||
150 | final public function isSent() |
||
154 | |||
155 | /** |
||
156 | * Check if notification status is pending. |
||
157 | * |
||
158 | * @return bool |
||
159 | */ |
||
160 | final public function isPending() |
||
164 | |||
165 | /** |
||
166 | * Set notification status. |
||
167 | * |
||
168 | * @param int $status |
||
169 | * @param \Jgut\Tify\Result[] $results |
||
170 | * |
||
171 | * @throws \InvalidArgumentException |
||
172 | * |
||
173 | * @return $this |
||
174 | */ |
||
175 | final public function setStatus($status, array $results = []) |
||
190 | |||
191 | /** |
||
192 | * Retrieve results. |
||
193 | * |
||
194 | * @return \Jgut\Tify\Result[] |
||
195 | */ |
||
196 | final public function getResults() |
||
200 | |||
201 | /** |
||
202 | * Retrieve recipients tokens list. |
||
203 | * |
||
204 | * @return string[] |
||
|
|||
205 | */ |
||
206 | final public function getTokens() |
||
210 | } |
||
211 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.