1 | <?php |
||
19 | class EmailSendCheck extends AbstractEmailCheck |
||
20 | { |
||
21 | const CHECK = 'email-send-check'; |
||
22 | const MESSAGE_BODY = 'This is a test, you don\'t need to reply this massage.'; |
||
23 | const SEND_INTERVAL = 600; |
||
24 | const SUBJECT_TEMPLATE = '%s:time:%s'; |
||
25 | |||
26 | /** |
||
27 | * @var int |
||
28 | */ |
||
29 | private $sendInterval; |
||
30 | |||
31 | /** |
||
32 | * @var Swift_Mailer |
||
33 | */ |
||
34 | private $mailer; |
||
35 | |||
36 | /** |
||
37 | * @var PersistCollectionInterface |
||
38 | */ |
||
39 | private $persistCollection; |
||
40 | |||
41 | /** |
||
42 | * @var EmailSendReceiveCollection |
||
43 | */ |
||
44 | private $emailSendReceiveCollection; |
||
45 | |||
46 | /** |
||
47 | * @var string; |
||
48 | */ |
||
49 | private $from; |
||
50 | |||
51 | /** |
||
52 | * @var string; |
||
53 | */ |
||
54 | private $toSubject; |
||
55 | |||
56 | /** |
||
57 | * @param string $checkNode |
||
58 | * @param Swift_Mailer $mailer |
||
59 | * @param string $from |
||
60 | * @param string $toSubjects |
||
61 | * @param int $sendInterval |
||
62 | */ |
||
63 | 8 | public function __construct( |
|
79 | |||
80 | /** |
||
81 | * Check email can send and receive messages. |
||
82 | * |
||
83 | * @return void |
||
84 | * |
||
85 | * @throws EmailSendCheckException |
||
86 | */ |
||
87 | 7 | public function performCheck() |
|
88 | { |
||
89 | 7 | $this->setEmailSendReceiveColl($this->getPersistCollection()->load()); |
|
90 | |||
91 | 7 | $lastSandedEmail = $this->getEmailSendReceiveColl()->count() - 1 >= 0 ? |
|
92 | 7 | $this->getEmailSendReceiveColl()->at( |
|
93 | 7 | $this->getEmailSendReceiveColl()->count() - 1 |
|
94 | 7 | ) |
|
95 | 7 | : null; |
|
96 | 7 | if (null === $lastSandedEmail |
|
97 | 7 | || empty($lastSandedEmail->getSentAt()) |
|
98 | 7 | || (time() - $lastSandedEmail->getSentAt()->getTimestamp()) > $this->getSendInterval() |
|
99 | 7 | ) { |
|
100 | 6 | $emailSendCheck = $this->createEmailSendReceive(); |
|
101 | |||
102 | 6 | $this->performSend($emailSendCheck); |
|
103 | 2 | } |
|
104 | 3 | } |
|
105 | |||
106 | /** |
||
107 | * @return Swift_Mailer |
||
108 | */ |
||
109 | 6 | public function getMailer() |
|
113 | |||
114 | /** |
||
115 | * @return PersistCollectionInterface |
||
116 | */ |
||
117 | 7 | public function getPersistCollection() |
|
121 | |||
122 | /** |
||
123 | * @return EmailSendReceiveCollection |
||
124 | */ |
||
125 | 7 | public function getEmailSendReceiveColl() |
|
129 | |||
130 | /** |
||
131 | * @return string |
||
132 | */ |
||
133 | 6 | public function getFrom() |
|
137 | |||
138 | /** |
||
139 | * @return string |
||
140 | */ |
||
141 | 6 | public function getToSubject() |
|
145 | |||
146 | /** |
||
147 | * @return int |
||
148 | */ |
||
149 | 7 | public function getSendInterval() |
|
153 | |||
154 | /** |
||
155 | * @param Swift_Mailer $mailer |
||
156 | */ |
||
157 | 8 | protected function setMailer(Swift_Mailer $mailer) |
|
161 | |||
162 | /** |
||
163 | * @param PersistCollectionInterface $persistCollection |
||
164 | */ |
||
165 | 8 | protected function setPersistCollection(PersistCollectionInterface $persistCollection) |
|
169 | |||
170 | /** |
||
171 | * @param EmailSendReceiveCollection $emailSendReceiveC |
||
172 | */ |
||
173 | 7 | protected function setEmailSendReceiveColl(EmailSendReceiveCollection $emailSendReceiveC) |
|
177 | |||
178 | /** |
||
179 | * @param string $from |
||
180 | */ |
||
181 | 8 | protected function setFrom($from) |
|
185 | |||
186 | /** |
||
187 | * @param string $toSubject |
||
188 | */ |
||
189 | 8 | protected function setToSubject($toSubject) |
|
193 | |||
194 | /** |
||
195 | * @return string |
||
196 | */ |
||
197 | 6 | protected function genEmailSubject() |
|
201 | |||
202 | /** |
||
203 | * @param int $sendInterval |
||
204 | */ |
||
205 | 8 | protected function setSendInterval($sendInterval) |
|
209 | |||
210 | /** |
||
211 | * @return EmailSendReceive |
||
212 | */ |
||
213 | 6 | protected function createEmailSendReceive() |
|
224 | |||
225 | /** |
||
226 | * @param Swift_Mime_Message $message |
||
227 | * @param EmailSendReceive $emailSendCheck |
||
228 | * |
||
229 | * @throws EmailSendCheckException |
||
230 | */ |
||
231 | 6 | protected function sendMessage(Swift_Mime_Message $message, EmailSendReceive $emailSendCheck) |
|
241 | |||
242 | /** |
||
243 | * @param EmailSendReceive $emailSendCheck |
||
244 | * |
||
245 | * @return Swift_Mime_MimePart |
||
246 | */ |
||
247 | 6 | protected function buildMessage(EmailSendReceive $emailSendCheck) |
|
256 | |||
257 | /** |
||
258 | * @param EmailSendReceive $emailSendCheck |
||
259 | */ |
||
260 | 3 | private function saveEmailSendReceive(EmailSendReceive $emailSendCheck) |
|
265 | |||
266 | /** |
||
267 | * @param EmailSendReceive $emailSendCheck |
||
268 | * |
||
269 | * @throws EmailSendCheckException |
||
270 | */ |
||
271 | 6 | private function performSend(EmailSendReceive $emailSendCheck) |
|
286 | } |
||
287 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: