@@ -121,7 +121,7 @@ |
||
121 | 121 | protected function parse(){ |
122 | 122 | if ($this->header === null) { |
123 | 123 | $body = $this->findHeaders(); |
124 | - }else{ |
|
124 | + } else{ |
|
125 | 125 | $body = $this->raw; |
126 | 126 | } |
127 | 127 |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @throws InvalidMessageDateException |
161 | 161 | */ |
162 | - protected function parse(){ |
|
162 | + protected function parse() { |
|
163 | 163 | if ($this->header === null) { |
164 | 164 | $body = $this->findHeaders(); |
165 | - }else{ |
|
165 | + }else { |
|
166 | 166 | $body = $this->raw; |
167 | 167 | } |
168 | 168 | |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | $this->name = $this->header->get("name"); |
175 | 175 | $this->filename = $this->header->get("filename"); |
176 | 176 | |
177 | - if(!empty($this->header->get("id"))) { |
|
177 | + if (!empty($this->header->get("id"))) { |
|
178 | 178 | $this->id = $this->header->get("id"); |
179 | - } else if(!empty($this->header->get("x_attachment_id"))){ |
|
179 | + }else if (!empty($this->header->get("x_attachment_id"))) { |
|
180 | 180 | $this->id = $this->header->get("x_attachment_id"); |
181 | - } else if(!empty($this->header->get("content_id"))){ |
|
181 | + }else if (!empty($this->header->get("content_id"))) { |
|
182 | 182 | $this->id = strtr($this->header->get("content_id"), [ |
183 | 183 | '<' => '', |
184 | 184 | '>' => '' |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | $content_types = $this->header->get("content_type"); |
189 | - if(!empty($content_types)){ |
|
189 | + if (!empty($content_types)) { |
|
190 | 190 | $this->subtype = $this->parseSubtype($content_types); |
191 | 191 | $content_type = $content_types; |
192 | 192 | if (is_array($content_types)) { |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @return string |
208 | 208 | * @throws InvalidMessageDateException |
209 | 209 | */ |
210 | - private function findHeaders(){ |
|
210 | + private function findHeaders() { |
|
211 | 211 | $body = $this->raw; |
212 | 212 | while (($pos = strpos($body, "\r\n")) > 0) { |
213 | 213 | $body = substr($body, $pos + 2); |
@@ -226,16 +226,16 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - private function parseSubtype($content_type){ |
|
229 | + private function parseSubtype($content_type) { |
|
230 | 230 | if (is_array($content_type)) { |
231 | - foreach ($content_type as $part){ |
|
232 | - if ((strpos($part, "/")) !== false){ |
|
231 | + foreach ($content_type as $part) { |
|
232 | + if ((strpos($part, "/")) !== false) { |
|
233 | 233 | return $this->parseSubtype($part); |
234 | 234 | } |
235 | 235 | } |
236 | 236 | return null; |
237 | 237 | } |
238 | - if (($pos = strpos($content_type, "/")) !== false){ |
|
238 | + if (($pos = strpos($content_type, "/")) !== false) { |
|
239 | 239 | return substr($content_type, $pos + 1); |
240 | 240 | } |
241 | 241 | return null; |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | /** |
245 | 245 | * Try to parse the disposition if any is present |
246 | 246 | */ |
247 | - private function parseDisposition(){ |
|
247 | + private function parseDisposition() { |
|
248 | 248 | $content_disposition = $this->header->get("content_disposition"); |
249 | - if($content_disposition !== null) { |
|
249 | + if ($content_disposition !== null) { |
|
250 | 250 | $this->ifdisposition = true; |
251 | 251 | $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition; |
252 | 252 | } |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | /** |
256 | 256 | * Try to parse the description if any is present |
257 | 257 | */ |
258 | - private function parseDescription(){ |
|
258 | + private function parseDescription() { |
|
259 | 259 | $content_description = $this->header->get("content_description"); |
260 | - if($content_description !== null) { |
|
260 | + if ($content_description !== null) { |
|
261 | 261 | $this->ifdescription = true; |
262 | 262 | $this->description = $content_description; |
263 | 263 | } |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | /** |
267 | 267 | * Try to parse the encoding if any is present |
268 | 268 | */ |
269 | - private function parseEncoding(){ |
|
269 | + private function parseEncoding() { |
|
270 | 270 | $encoding = $this->header->get("content_transfer_encoding"); |
271 | - if($encoding !== null) { |
|
271 | + if ($encoding !== null) { |
|
272 | 272 | switch (strtolower($encoding)) { |
273 | 273 | case "quoted-printable": |
274 | 274 | $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return bool |
300 | 300 | */ |
301 | - public function isAttachment(){ |
|
301 | + public function isAttachment() { |
|
302 | 302 | $valid_disposition = in_array(strtolower($this->disposition), ClientManager::get('options.dispositions')); |
303 | 303 | |
304 | 304 | if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition))) && !$valid_disposition) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $this->part_number = $part->part_number; |
105 | 105 | |
106 | 106 | $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask(); |
107 | - if($default_mask != null) { |
|
107 | + if ($default_mask != null) { |
|
108 | 108 | $this->mask = $default_mask; |
109 | 109 | } |
110 | 110 | |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | * @throws MethodNotFoundException |
122 | 122 | */ |
123 | 123 | public function __call($method, $arguments) { |
124 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
124 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
125 | 125 | $name = Str::snake(substr($method, 3)); |
126 | 126 | |
127 | - if(isset($this->attributes[$name])) { |
|
127 | + if (isset($this->attributes[$name])) { |
|
128 | 128 | return $this->attributes[$name]; |
129 | 129 | } |
130 | 130 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return mixed|null |
161 | 161 | */ |
162 | 162 | public function __get($name) { |
163 | - if(isset($this->attributes[$name])) { |
|
163 | + if (isset($this->attributes[$name])) { |
|
164 | 164 | return $this->attributes[$name]; |
165 | 165 | } |
166 | 166 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) { |
230 | 230 | if ($this->part->ifdescription) { |
231 | 231 | $this->setName($this->part->description); |
232 | - } else { |
|
232 | + }else { |
|
233 | 233 | $this->setName($this->part->subtype); |
234 | 234 | } |
235 | 235 | } |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | public function setName($name) { |
256 | 256 | $decoder = $this->config['decoder']['attachment']; |
257 | 257 | if ($name !== null) { |
258 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
258 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
259 | 259 | $this->name = \imap_utf8($name); |
260 | - }else{ |
|
260 | + }else { |
|
261 | 261 | $this->name = mb_decode_mimeheader($name); |
262 | 262 | } |
263 | 263 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return string|null |
270 | 270 | */ |
271 | - public function getMimeType(){ |
|
271 | + public function getMimeType() { |
|
272 | 272 | return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE); |
273 | 273 | } |
274 | 274 | |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return string|null |
279 | 279 | */ |
280 | - public function getExtension(){ |
|
280 | + public function getExtension() { |
|
281 | 281 | $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser"; |
282 | - if (class_exists($deprecated_guesser) !== false){ |
|
282 | + if (class_exists($deprecated_guesser) !== false) { |
|
283 | 283 | return $deprecated_guesser::getInstance()->guess($this->getMimeType()); |
284 | 284 | } |
285 | 285 | $guesser = "\Symfony\Component\Mime\MimeTypes"; |
@@ -292,14 +292,14 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return array |
294 | 294 | */ |
295 | - public function getAttributes(){ |
|
295 | + public function getAttributes() { |
|
296 | 296 | return $this->attributes; |
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
300 | 300 | * @return Message |
301 | 301 | */ |
302 | - public function getMessage(){ |
|
302 | + public function getMessage() { |
|
303 | 303 | return $this->oMessage; |
304 | 304 | } |
305 | 305 | |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @return $this |
311 | 311 | */ |
312 | - public function setMask($mask){ |
|
313 | - if(class_exists($mask)){ |
|
312 | + public function setMask($mask) { |
|
313 | + if (class_exists($mask)) { |
|
314 | 314 | $this->mask = $mask; |
315 | 315 | } |
316 | 316 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @return string |
324 | 324 | */ |
325 | - public function getMask(){ |
|
325 | + public function getMask() { |
|
326 | 326 | return $this->mask; |
327 | 327 | } |
328 | 328 | |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | * @return mixed |
334 | 334 | * @throws MaskNotFoundException |
335 | 335 | */ |
336 | - public function mask($mask = null){ |
|
336 | + public function mask($mask = null) { |
|
337 | 337 | $mask = $mask !== null ? $mask : $this->mask; |
338 | - if(class_exists($mask)){ |
|
338 | + if (class_exists($mask)) { |
|
339 | 339 | return new $mask($this); |
340 | 340 | } |
341 | 341 |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | return null; |
131 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
131 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
132 | 132 | $name = Str::snake(substr($method, 3)); |
133 | 133 | |
134 | 134 | $this->attributes[$name] = array_pop($arguments); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $this->setName($filename); |
223 | 223 | } elseif (($name = $this->part->name) !== null) { |
224 | 224 | $this->setName($name); |
225 | - }else { |
|
225 | + } else { |
|
226 | 226 | $this->setName("undefined"); |
227 | 227 | } |
228 | 228 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | if ($name !== null) { |
258 | 258 | if($decoder === 'utf-8' && extension_loaded('imap')) { |
259 | 259 | $this->name = \imap_utf8($name); |
260 | - }else{ |
|
260 | + } else{ |
|
261 | 261 | $this->name = mb_decode_mimeheader($name); |
262 | 262 | } |
263 | 263 | } |
@@ -232,7 +232,9 @@ discard block |
||
232 | 232 | public function move($new_name, $expunge = true) { |
233 | 233 | $this->client->checkConnection(); |
234 | 234 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
235 | - if($expunge) $this->client->expunge(); |
|
235 | + if($expunge) { |
|
236 | + $this->client->expunge(); |
|
237 | + } |
|
236 | 238 | |
237 | 239 | $folder = $this->client->getFolder($new_name); |
238 | 240 | $event = $this->getEvent("folder", "moved"); |
@@ -306,7 +308,9 @@ discard block |
||
306 | 308 | */ |
307 | 309 | public function delete($expunge = true) { |
308 | 310 | $status = $this->client->getConnection()->deleteFolder($this->path); |
309 | - if($expunge) $this->client->expunge(); |
|
311 | + if($expunge) { |
|
312 | + $this->client->expunge(); |
|
313 | + } |
|
310 | 314 | |
311 | 315 | $event = $this->getEvent("folder", "deleted"); |
312 | 316 | $event::dispatch($this); |
@@ -374,7 +378,7 @@ discard block |
||
374 | 378 | |
375 | 379 | $connection->idle(); |
376 | 380 | } |
377 | - }catch (Exceptions\RuntimeException $e) { |
|
381 | + } catch (Exceptions\RuntimeException $e) { |
|
378 | 382 | if(strpos($e->getMessage(), "connection closed") === false) { |
379 | 383 | throw $e; |
380 | 384 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | $this->setDelimiter($delimiter); |
124 | 124 | $this->path = $folder_name; |
125 | - $this->full_name = $this->decodeName($folder_name); |
|
125 | + $this->full_name = $this->decodeName($folder_name); |
|
126 | 126 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
127 | 127 | |
128 | 128 | $this->parseAttributes($attributes); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @throws Exceptions\ConnectionFailedException |
137 | 137 | * @throws Exceptions\RuntimeException |
138 | 138 | */ |
139 | - public function query($extensions = []){ |
|
139 | + public function query($extensions = []) { |
|
140 | 140 | $this->getClient()->checkConnection(); |
141 | 141 | $this->getClient()->openFolder($this->path); |
142 | 142 | $extensions = count($extensions) > 0 ? $extensions : $this->getClient()->extensions; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @throws Exceptions\ConnectionFailedException |
150 | 150 | * @throws Exceptions\RuntimeException |
151 | 151 | */ |
152 | - public function search($extensions = 'UTF-8'){ |
|
152 | + public function search($extensions = 'UTF-8') { |
|
153 | 153 | return $this->query($extensions); |
154 | 154 | } |
155 | 155 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @throws Exceptions\ConnectionFailedException |
159 | 159 | * @throws Exceptions\RuntimeException |
160 | 160 | */ |
161 | - public function messages($extensions = []){ |
|
161 | + public function messages($extensions = []) { |
|
162 | 162 | return $this->query($extensions); |
163 | 163 | } |
164 | 164 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | public function move($new_name, $expunge = true) { |
234 | 234 | $this->client->checkConnection(); |
235 | 235 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
236 | - if($expunge) $this->client->expunge(); |
|
236 | + if ($expunge) $this->client->expunge(); |
|
237 | 237 | |
238 | 238 | $folder = $this->client->getFolder($new_name); |
239 | 239 | $event = $this->getEvent("folder", "moved"); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @throws Exceptions\MessageNotFoundException |
253 | 253 | * @throws Exceptions\RuntimeException |
254 | 254 | */ |
255 | - public function overview($sequence = null){ |
|
255 | + public function overview($sequence = null) { |
|
256 | 256 | $this->client->openFolder($this->path); |
257 | 257 | $sequence = $sequence === null ? "1:*" : $sequence; |
258 | 258 | $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | |
279 | 279 | if ($internal_date != null) { |
280 | - if ($internal_date instanceof Carbon){ |
|
280 | + if ($internal_date instanceof Carbon) { |
|
281 | 281 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
282 | 282 | } |
283 | 283 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function delete($expunge = true) { |
313 | 313 | $status = $this->client->getConnection()->deleteFolder($this->path); |
314 | - if($expunge) $this->client->expunge(); |
|
314 | + if ($expunge) $this->client->expunge(); |
|
315 | 315 | |
316 | 316 | $event = $this->getEvent("folder", "deleted"); |
317 | 317 | $event::dispatch($this); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | try { |
373 | 373 | $line = $connection->nextLine(); |
374 | 374 | if (($pos = strpos($line, "EXISTS")) !== false) { |
375 | - $msgn = (int) substr($line, 2, $pos -2); |
|
375 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
376 | 376 | $connection->done(); |
377 | 377 | |
378 | 378 | $this->client->openFolder($this->path, true); |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | |
386 | 386 | $connection->idle(); |
387 | 387 | } |
388 | - }catch (Exceptions\RuntimeException $e) { |
|
389 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
388 | + } catch (Exceptions\RuntimeException $e) { |
|
389 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
390 | 390 | throw $e; |
391 | 391 | } |
392 | 392 | if ($auto_reconnect === true) { |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | * Set the delimiter |
436 | 436 | * @param $delimiter |
437 | 437 | */ |
438 | - public function setDelimiter($delimiter){ |
|
439 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
438 | + public function setDelimiter($delimiter) { |
|
439 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
440 | 440 | $delimiter = ClientManager::get('options.delimiter', '/'); |
441 | 441 | } |
442 | 442 |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @param object $object |
45 | 45 | */ |
46 | 46 | public function __construct($object) { |
47 | - if (property_exists($object, "personal")){ $this->personal = $object->personal; } |
|
48 | - if (property_exists($object, "mailbox")){ $this->mailbox = $object->mailbox; } |
|
49 | - if (property_exists($object, "host")){ $this->host = $object->host; } |
|
50 | - if (property_exists($object, "mail")){ $this->mail = $object->mail; } |
|
51 | - if (property_exists($object, "full")){ $this->full = $object->full; } |
|
47 | + if (property_exists($object, "personal")) { $this->personal = $object->personal; } |
|
48 | + if (property_exists($object, "mailbox")) { $this->mailbox = $object->mailbox; } |
|
49 | + if (property_exists($object, "host")) { $this->host = $object->host; } |
|
50 | + if (property_exists($object, "mail")) { $this->mail = $object->mail; } |
|
51 | + if (property_exists($object, "full")) { $this->full = $object->full; } |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - public function __serialize(){ |
|
69 | + public function __serialize() { |
|
70 | 70 | return [ |
71 | 71 | "personal" => $this->personal, |
72 | 72 | "mailbox" => $this->mailbox, |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return array |
83 | 83 | */ |
84 | - public function toArray(){ |
|
84 | + public function toArray() { |
|
85 | 85 | return $this->__serialize(); |
86 | 86 | } |
87 | 87 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - public function toString(){ |
|
93 | + public function toString() { |
|
94 | 94 | return $this->__toString(); |
95 | 95 | } |
96 | 96 | } |
97 | 97 | \ No newline at end of file |
@@ -233,7 +233,9 @@ discard block |
||
233 | 233 | } else { |
234 | 234 | $tokens = $line; |
235 | 235 | } |
236 | - if ($this->debug) echo "<< ".$line."\n"; |
|
236 | + if ($this->debug) { |
|
237 | + echo "<< ".$line."\n"; |
|
238 | + } |
|
237 | 239 | |
238 | 240 | // if tag is wanted tag we might be at the end of a multiline response |
239 | 241 | return $tag == $wantedTag; |
@@ -298,7 +300,9 @@ discard block |
||
298 | 300 | $line .= ' ' . $token; |
299 | 301 | } |
300 | 302 | } |
301 | - if ($this->debug) echo ">> ".$line."\n"; |
|
303 | + if ($this->debug) { |
|
304 | + echo ">> ".$line."\n"; |
|
305 | + } |
|
302 | 306 | |
303 | 307 | if (fwrite($this->stream, $line . "\r\n") === false) { |
304 | 308 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -448,7 +452,9 @@ discard block |
||
448 | 452 | public function getCapabilities() { |
449 | 453 | $response = $this->requestAndResponse('CAPABILITY'); |
450 | 454 | |
451 | - if (!$response) return []; |
|
455 | + if (!$response) { |
|
456 | + return []; |
|
457 | + } |
|
452 | 458 | |
453 | 459 | $capabilities = []; |
454 | 460 | foreach ($response as $line) { |
@@ -605,13 +611,14 @@ discard block |
||
605 | 611 | // if we want only one message we can ignore everything else and just return |
606 | 612 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
607 | 613 | // we still need to read all lines |
608 | - while (!$this->readLine($tokens, $tag)) |
|
609 | - |
|
614 | + while (!$this->readLine($tokens, $tag)) { |
|
615 | + |
|
610 | 616 | return $data; |
617 | + } |
|
611 | 618 | } |
612 | 619 | if ($uid) { |
613 | 620 | $result[$tokens[2][$uidKey]] = $data; |
614 | - }else{ |
|
621 | + } else{ |
|
615 | 622 | $result[$tokens[0]] = $data; |
616 | 623 | } |
617 | 624 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @throws ConnectionFailedException |
90 | 90 | * @throws RuntimeException |
91 | 91 | */ |
92 | - protected function enableTls(){ |
|
92 | + protected function enableTls() { |
|
93 | 93 | $response = $this->requestAndResponse('STARTTLS'); |
94 | 94 | $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod()); |
95 | 95 | if (!$result) { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $stack = []; |
152 | 152 | |
153 | 153 | // replace any trailing <NL> including spaces with a single space |
154 | - $line = rtrim($line) . ' '; |
|
154 | + $line = rtrim($line).' '; |
|
155 | 155 | while (($pos = strpos($line, ' ')) !== false) { |
156 | 156 | $token = substr($line, 0, $pos); |
157 | 157 | if (!strlen($token)) { |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | if (strlen($token) > $chars) { |
182 | 182 | $line = substr($token, $chars); |
183 | 183 | $token = substr($token, 0, $chars); |
184 | - } else { |
|
184 | + }else { |
|
185 | 185 | $line .= $this->nextLine(); |
186 | 186 | } |
187 | 187 | $tokens[] = $token; |
188 | - $line = trim($line) . ' '; |
|
188 | + $line = trim($line).' '; |
|
189 | 189 | continue; |
190 | 190 | } |
191 | 191 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $line = $this->nextTaggedLine($tag); // get next tag |
236 | 236 | if (!$dontParse) { |
237 | 237 | $tokens = $this->decodeLine($line); |
238 | - } else { |
|
238 | + }else { |
|
239 | 239 | $tokens = $line; |
240 | 240 | } |
241 | 241 | if ($this->debug) echo "<< ".$line."\n"; |
@@ -286,27 +286,27 @@ discard block |
||
286 | 286 | public function sendRequest($command, $tokens = [], &$tag = null) { |
287 | 287 | if (!$tag) { |
288 | 288 | $this->noun++; |
289 | - $tag = 'TAG' . $this->noun; |
|
289 | + $tag = 'TAG'.$this->noun; |
|
290 | 290 | } |
291 | 291 | |
292 | - $line = $tag . ' ' . $command; |
|
292 | + $line = $tag.' '.$command; |
|
293 | 293 | |
294 | 294 | foreach ($tokens as $token) { |
295 | 295 | if (is_array($token)) { |
296 | - if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) { |
|
296 | + if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) { |
|
297 | 297 | throw new RuntimeException('failed to write - connection closed?'); |
298 | 298 | } |
299 | 299 | if (!$this->assumedNextLine('+ ')) { |
300 | 300 | throw new RuntimeException('failed to send literal string'); |
301 | 301 | } |
302 | 302 | $line = $token[1]; |
303 | - } else { |
|
304 | - $line .= ' ' . $token; |
|
303 | + }else { |
|
304 | + $line .= ' '.$token; |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | if ($this->debug) echo ">> ".$line."\n"; |
308 | 308 | |
309 | - if (fwrite($this->stream, $line . "\r\n") === false) { |
|
309 | + if (fwrite($this->stream, $line."\r\n") === false) { |
|
310 | 310 | throw new RuntimeException('failed to write - connection closed?'); |
311 | 311 | } |
312 | 312 | } |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | public function escapeString($string) { |
337 | 337 | if (func_num_args() < 2) { |
338 | 338 | if (strpos($string, "\n") !== false) { |
339 | - return ['{' . strlen($string) . '}', $string]; |
|
340 | - } else { |
|
341 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
339 | + return ['{'.strlen($string).'}', $string]; |
|
340 | + }else { |
|
341 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | $result = []; |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | } |
364 | 364 | $result[] = $this->escapeList($v); |
365 | 365 | } |
366 | - return '(' . implode(' ', $result) . ')'; |
|
366 | + return '('.implode(' ', $result).')'; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -403,12 +403,12 @@ discard block |
||
403 | 403 | error_log("got an extra server challenge: $response"); |
404 | 404 | // respond with an empty response. |
405 | 405 | $this->sendRequest(''); |
406 | - } else { |
|
406 | + }else { |
|
407 | 407 | if (preg_match('/^NO /i', $response) || |
408 | 408 | preg_match('/^BAD /i', $response)) { |
409 | 409 | error_log("got failure response: $response"); |
410 | 410 | return false; |
411 | - } else if (preg_match("/^OK /i", $response)) { |
|
411 | + }else if (preg_match("/^OK /i", $response)) { |
|
412 | 412 | return true; |
413 | 413 | } |
414 | 414 | } |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @return bool |
443 | 443 | */ |
444 | - public function connected(){ |
|
444 | + public function connected() { |
|
445 | 445 | return (boolean) $this->stream; |
446 | 446 | } |
447 | 447 | |
@@ -488,10 +488,10 @@ discard block |
||
488 | 488 | $result[strtolower($tokens[1])] = $tokens[0]; |
489 | 489 | break; |
490 | 490 | case '[UIDVALIDITY': |
491 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
491 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
492 | 492 | break; |
493 | 493 | case '[UIDNEXT': |
494 | - $result['uidnext'] = (int)$tokens[2]; |
|
494 | + $result['uidnext'] = (int) $tokens[2]; |
|
495 | 495 | break; |
496 | 496 | default: |
497 | 497 | // ignore |
@@ -546,17 +546,17 @@ discard block |
||
546 | 546 | if (is_array($from)) { |
547 | 547 | $set = implode(',', $from); |
548 | 548 | } elseif ($to === null) { |
549 | - $set = (int)$from; |
|
549 | + $set = (int) $from; |
|
550 | 550 | } elseif ($to === INF) { |
551 | - $set = (int)$from . ':*'; |
|
552 | - } else { |
|
553 | - $set = (int)$from . ':' . (int)$to; |
|
551 | + $set = (int) $from.':*'; |
|
552 | + }else { |
|
553 | + $set = (int) $from.':'.(int) $to; |
|
554 | 554 | } |
555 | 555 | |
556 | - $items = (array)$items; |
|
556 | + $items = (array) $items; |
|
557 | 557 | $itemList = $this->escapeList($items); |
558 | 558 | |
559 | - $this->sendRequest(trim($this->getUIDKey($uid) . ' FETCH'), [$set, $itemList], $tag); |
|
559 | + $this->sendRequest(trim($this->getUIDKey($uid).' FETCH'), [$set, $itemList], $tag); |
|
560 | 560 | $result = []; |
561 | 561 | $tokens = null; // define $tokens variable before first use |
562 | 562 | while (!$this->readLine($tokens, $tag)) { |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | $count = count($tokens[2]); |
571 | 571 | if ($tokens[2][$count - 2] == 'UID') { |
572 | 572 | $uidKey = $count - 1; |
573 | - } else if ($tokens[2][0] == 'UID') { |
|
573 | + }else if ($tokens[2][0] == 'UID') { |
|
574 | 574 | $uidKey = 1; |
575 | - } else { |
|
575 | + }else { |
|
576 | 576 | $uidKey = array_search('UID', $tokens[2]) + 1; |
577 | 577 | } |
578 | 578 | } |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | $data = $tokens[2][1]; |
589 | 589 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
590 | 590 | $data = $tokens[2][3]; |
591 | - } else { |
|
591 | + }else { |
|
592 | 592 | // maybe the server send an other field we didn't wanted |
593 | 593 | $count = count($tokens[2]); |
594 | 594 | // we start with 2, because 0 was already checked |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | break; |
601 | 601 | } |
602 | 602 | } |
603 | - } else { |
|
603 | + }else { |
|
604 | 604 | $data = []; |
605 | 605 | while (key($tokens[2]) !== null) { |
606 | 606 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | } |
618 | 618 | if ($uid) { |
619 | 619 | $result[$tokens[2][$uidKey]] = $data; |
620 | - }else{ |
|
620 | + }else { |
|
621 | 621 | $result[$tokens[0]] = $data; |
622 | 622 | } |
623 | 623 | } |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * @return array |
654 | 654 | * @throws RuntimeException |
655 | 655 | */ |
656 | - public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID){ |
|
656 | + public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID) { |
|
657 | 657 | return $this->fetch(["$rfc.HEADER"], $uids, null, $uid); |
658 | 658 | } |
659 | 659 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * @return array |
667 | 667 | * @throws RuntimeException |
668 | 668 | */ |
669 | - public function flags($uids, $uid = IMAP::ST_UID){ |
|
669 | + public function flags($uids, $uid = IMAP::ST_UID) { |
|
670 | 670 | return $this->fetch(["FLAGS"], $uids, null, $uid); |
671 | 671 | } |
672 | 672 | |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | $item = 'FLAGS'; |
758 | 758 | } |
759 | 759 | if ($mode == '+' || $mode == '-') { |
760 | - $item = $mode . $item; |
|
760 | + $item = $mode.$item; |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | if ($silent) { |
@@ -765,16 +765,16 @@ discard block |
||
765 | 765 | } |
766 | 766 | |
767 | 767 | $flags = $this->escapeList($flags); |
768 | - $set = (int)$from; |
|
768 | + $set = (int) $from; |
|
769 | 769 | if ($to !== null) { |
770 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
770 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | $command = ($uid ? "UID " : "")."STORE"; |
774 | 774 | $result = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
775 | 775 | |
776 | 776 | if ($silent) { |
777 | - return (bool)$result; |
|
777 | + return (bool) $result; |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | $tokens = $result; |
@@ -826,9 +826,9 @@ discard block |
||
826 | 826 | * @throws RuntimeException |
827 | 827 | */ |
828 | 828 | public function copyMessage($folder, $from, $to = null, $uid = IMAP::ST_UID) { |
829 | - $set = (int)$from; |
|
829 | + $set = (int) $from; |
|
830 | 830 | if ($to !== null) { |
831 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
831 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
832 | 832 | } |
833 | 833 | $command = trim($this->getUIDKey($uid)." COPY"); |
834 | 834 | return $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); |
@@ -867,9 +867,9 @@ discard block |
||
867 | 867 | * @throws RuntimeException |
868 | 868 | */ |
869 | 869 | public function moveMessage($folder, $from, $to = null, $uid = IMAP::ST_UID) { |
870 | - $set = (int)$from; |
|
870 | + $set = (int) $from; |
|
871 | 871 | if ($to !== null) { |
872 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
872 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
873 | 873 | } |
874 | 874 | $command = trim($this->getUIDKey($uid)." MOVE"); |
875 | 875 | |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | $ids = []; |
1083 | 1083 | foreach ($uids as $msgn => $v) { |
1084 | 1084 | $id = $uid ? $v : $msgn; |
1085 | - if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){ |
|
1085 | + if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) { |
|
1086 | 1086 | $ids[] = $id; |
1087 | 1087 | } |
1088 | 1088 | } |
@@ -1096,14 +1096,14 @@ discard block |
||
1096 | 1096 | /** |
1097 | 1097 | * Enable the debug mode |
1098 | 1098 | */ |
1099 | - public function enableDebug(){ |
|
1099 | + public function enableDebug() { |
|
1100 | 1100 | $this->debug = true; |
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | /** |
1104 | 1104 | * Disable the debug mode |
1105 | 1105 | */ |
1106 | - public function disableDebug(){ |
|
1106 | + public function disableDebug() { |
|
1107 | 1107 | $this->debug = false; |
1108 | 1108 | } |
1109 | 1109 | } |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | if(isset($this->attributes[$name]) && $strict === false) { |
131 | 131 | if ($this->attributize) { |
132 | 132 | $this->attributes[$name]->add($value, true); |
133 | - }else{ |
|
133 | + } else{ |
|
134 | 134 | if(isset($this->attributes[$name])) { |
135 | 135 | if (is_array($this->attributes[$name]) == false) { |
136 | 136 | $this->attributes[$name] = [$this->attributes[$name], $value]; |
137 | - }else{ |
|
137 | + } else{ |
|
138 | 138 | $this->attributes[$name][] = $value; |
139 | 139 | } |
140 | - }else{ |
|
140 | + } else{ |
|
141 | 141 | $this->attributes[$name] = $value; |
142 | 142 | } |
143 | 143 | } |
144 | - }elseif($this->attributize == false){ |
|
144 | + } elseif($this->attributize == false){ |
|
145 | 145 | $this->attributes[$name] = $value; |
146 | - }else{ |
|
146 | + } else{ |
|
147 | 147 | $this->attributes[$name] = new Attribute($name, $value); |
148 | 148 | } |
149 | 149 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | if ($prev_header !== null) { |
231 | 231 | $headers[$prev_header][] = $line; |
232 | 232 | } |
233 | - }elseif (substr($line, 0, 1) === " ") { |
|
233 | + } elseif (substr($line, 0, 1) === " ") { |
|
234 | 234 | $line = substr($line, 1); |
235 | 235 | $line = trim(rtrim($line)); |
236 | 236 | if ($prev_header !== null) { |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | } |
240 | 240 | if (is_array($headers[$prev_header])) { |
241 | 241 | $headers[$prev_header][] = $line; |
242 | - }else{ |
|
242 | + } else{ |
|
243 | 243 | $headers[$prev_header] .= $line; |
244 | 244 | } |
245 | 245 | } |
246 | - }else{ |
|
246 | + } else{ |
|
247 | 247 | if (($pos = strpos($line, ":")) > 0) { |
248 | 248 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
249 | 249 | $key = str_replace("-", "_", $key); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $value = trim(rtrim(substr($line, $pos + 1))); |
252 | 252 | if (isset($headers[$key])) { |
253 | 253 | $headers[$key][] = $value; |
254 | - }else{ |
|
254 | + } else{ |
|
255 | 255 | $headers[$key] = [$value]; |
256 | 256 | } |
257 | 257 | $prev_header = $key; |
@@ -260,7 +260,9 @@ discard block |
||
260 | 260 | } |
261 | 261 | |
262 | 262 | foreach($headers as $key => $values) { |
263 | - if (isset($imap_headers[$key])) continue; |
|
263 | + if (isset($imap_headers[$key])) { |
|
264 | + continue; |
|
265 | + } |
|
264 | 266 | $value = null; |
265 | 267 | switch($key){ |
266 | 268 | case 'from': |
@@ -397,9 +399,9 @@ discard block |
||
397 | 399 | return EncodingAliases::get($parameter->value, $this->fallback_encoding); |
398 | 400 | } |
399 | 401 | } |
400 | - }elseif (property_exists($structure, 'charset')) { |
|
402 | + } elseif (property_exists($structure, 'charset')) { |
|
401 | 403 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
402 | - }elseif (is_string($structure) === true){ |
|
404 | + } elseif (is_string($structure) === true){ |
|
403 | 405 | return mb_detect_encoding($structure); |
404 | 406 | } |
405 | 407 | |
@@ -446,9 +448,9 @@ discard block |
||
446 | 448 | } |
447 | 449 | } |
448 | 450 | } |
449 | - }elseif($decoder === 'iconv' && $is_utf8_base) { |
|
451 | + } elseif($decoder === 'iconv' && $is_utf8_base) { |
|
450 | 452 | $value = iconv_mime_decode($value); |
451 | - }elseif($is_utf8_base){ |
|
453 | + } elseif($is_utf8_base){ |
|
452 | 454 | $value = mb_decode_mimeheader($value); |
453 | 455 | } |
454 | 456 | |
@@ -481,7 +483,9 @@ discard block |
||
481 | 483 | * Try to extract the priority from a given raw header string |
482 | 484 | */ |
483 | 485 | private function findPriority() { |
484 | - if(($priority = $this->get("x_priority")) === null) return; |
|
486 | + if(($priority = $this->get("x_priority")) === null) { |
|
487 | + return; |
|
488 | + } |
|
485 | 489 | switch((int)"$priority"){ |
486 | 490 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
487 | 491 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
@@ -604,7 +608,7 @@ discard block |
||
604 | 608 | foreach ($this->attributes as $key => $value) { |
605 | 609 | if (is_array($value)) { |
606 | 610 | $value = implode(", ", $value); |
607 | - }else{ |
|
611 | + } else{ |
|
608 | 612 | $value = (string)$value; |
609 | 613 | } |
610 | 614 | // Only parse strings and don't parse any attributes like the user-agent |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * @throws MethodNotFoundException |
83 | 83 | */ |
84 | 84 | public function __call($method, $arguments) { |
85 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
85 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
86 | 86 | $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3)); |
87 | 87 | |
88 | - if(in_array($name, array_keys($this->attributes))) { |
|
88 | + if (in_array($name, array_keys($this->attributes))) { |
|
89 | 89 | return $this->attributes[$name]; |
90 | 90 | } |
91 | 91 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return Attribute|mixed |
112 | 112 | */ |
113 | 113 | public function get($name) { |
114 | - if(isset($this->attributes[$name])) { |
|
114 | + if (isset($this->attributes[$name])) { |
|
115 | 115 | return $this->attributes[$name]; |
116 | 116 | } |
117 | 117 | |
@@ -127,23 +127,23 @@ discard block |
||
127 | 127 | * @return Attribute |
128 | 128 | */ |
129 | 129 | public function set($name, $value, $strict = false) { |
130 | - if(isset($this->attributes[$name]) && $strict === false) { |
|
130 | + if (isset($this->attributes[$name]) && $strict === false) { |
|
131 | 131 | if ($this->attributize) { |
132 | 132 | $this->attributes[$name]->add($value, true); |
133 | - }else{ |
|
134 | - if(isset($this->attributes[$name])) { |
|
133 | + }else { |
|
134 | + if (isset($this->attributes[$name])) { |
|
135 | 135 | if (is_array($this->attributes[$name]) == false) { |
136 | 136 | $this->attributes[$name] = [$this->attributes[$name], $value]; |
137 | - }else{ |
|
137 | + }else { |
|
138 | 138 | $this->attributes[$name][] = $value; |
139 | 139 | } |
140 | - }else{ |
|
140 | + }else { |
|
141 | 141 | $this->attributes[$name] = $value; |
142 | 142 | } |
143 | 143 | } |
144 | - }elseif($this->attributize == false){ |
|
144 | + }elseif ($this->attributize == false) { |
|
145 | 145 | $this->attributes[$name] = $value; |
146 | - }else{ |
|
146 | + }else { |
|
147 | 147 | $this->attributes[$name] = new Attribute($name, $value); |
148 | 148 | } |
149 | 149 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | public function find($pattern) { |
160 | 160 | if (preg_match_all($pattern, $this->raw, $matches)) { |
161 | 161 | if (isset($matches[1])) { |
162 | - if(count($matches[1]) > 0) { |
|
162 | + if (count($matches[1]) > 0) { |
|
163 | 163 | return $matches[1][0]; |
164 | 164 | } |
165 | 165 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return string|null |
174 | 174 | */ |
175 | - public function getBoundary(){ |
|
175 | + public function getBoundary() { |
|
176 | 176 | $regex = isset($this->config["boundary"]) ? $this->config["boundary"] : "/boundary=(.*?(?=;)|(.*))/i"; |
177 | 177 | $boundary = $this->find($regex); |
178 | 178 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @throws InvalidMessageDateException |
200 | 200 | */ |
201 | - protected function parse(){ |
|
201 | + protected function parse() { |
|
202 | 202 | $header = $this->rfc822_parse_headers($this->raw); |
203 | 203 | |
204 | 204 | $this->extractAddresses($header); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $this->parseDate($header); |
217 | 217 | foreach ($header as $key => $value) { |
218 | 218 | $key = trim(rtrim(strtolower($key))); |
219 | - if(!isset($this->attributes[$key])){ |
|
219 | + if (!isset($this->attributes[$key])) { |
|
220 | 220 | $this->set($key, $value); |
221 | 221 | } |
222 | 222 | } |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return object |
234 | 234 | */ |
235 | - public function rfc822_parse_headers($raw_headers){ |
|
235 | + public function rfc822_parse_headers($raw_headers) { |
|
236 | 236 | $headers = []; |
237 | 237 | $imap_headers = []; |
238 | 238 | if (extension_loaded('imap') && $this->config["rfc822"]) { |
239 | 239 | $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw); |
240 | - foreach($raw_imap_headers as $key => $values) { |
|
240 | + foreach ($raw_imap_headers as $key => $values) { |
|
241 | 241 | $key = str_replace("-", "_", $key); |
242 | 242 | $imap_headers[$key] = $values; |
243 | 243 | } |
244 | 244 | } |
245 | 245 | $lines = explode("\r\n", str_replace("\r\n\t", ' ', $raw_headers)); |
246 | 246 | $prev_header = null; |
247 | - foreach($lines as $line) { |
|
247 | + foreach ($lines as $line) { |
|
248 | 248 | if (substr($line, 0, 1) === "\n") { |
249 | 249 | $line = substr($line, 1); |
250 | 250 | } |
@@ -264,19 +264,19 @@ discard block |
||
264 | 264 | } |
265 | 265 | if (is_array($headers[$prev_header])) { |
266 | 266 | $headers[$prev_header][] = $line; |
267 | - }else{ |
|
267 | + }else { |
|
268 | 268 | $headers[$prev_header] .= $line; |
269 | 269 | } |
270 | 270 | } |
271 | - }else{ |
|
271 | + }else { |
|
272 | 272 | if (($pos = strpos($line, ":")) > 0) { |
273 | 273 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
274 | 274 | $key = str_replace("-", "_", $key); |
275 | 275 | |
276 | 276 | $value = trim(rtrim(substr($line, $pos + 1))); |
277 | 277 | if (isset($headers[$key])) { |
278 | - $headers[$key][] = $value; |
|
279 | - }else{ |
|
278 | + $headers[$key][] = $value; |
|
279 | + }else { |
|
280 | 280 | $headers[$key] = [$value]; |
281 | 281 | } |
282 | 282 | $prev_header = $key; |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - foreach($headers as $key => $values) { |
|
287 | + foreach ($headers as $key => $values) { |
|
288 | 288 | if (isset($imap_headers[$key])) continue; |
289 | 289 | $value = null; |
290 | - switch($key){ |
|
290 | + switch ($key) { |
|
291 | 291 | case 'from': |
292 | 292 | case 'to': |
293 | 293 | case 'cc': |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | break; |
303 | 303 | default: |
304 | 304 | if (is_array($values)) { |
305 | - foreach($values as $k => $v) { |
|
305 | + foreach ($values as $k => $v) { |
|
306 | 306 | if ($v == "") { |
307 | 307 | unset($values[$k]); |
308 | 308 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $value = implode(" ", $values); |
315 | 315 | } elseif ($available_values > 2) { |
316 | 316 | $value = array_values($values); |
317 | - } else { |
|
317 | + }else { |
|
318 | 318 | $value = ""; |
319 | 319 | } |
320 | 320 | } |
@@ -334,12 +334,12 @@ discard block |
||
334 | 334 | * @return array The decoded elements are returned in an array of objects, where each |
335 | 335 | * object has two properties, charset and text. |
336 | 336 | */ |
337 | - public function mime_header_decode($text){ |
|
337 | + public function mime_header_decode($text) { |
|
338 | 338 | if (extension_loaded('imap')) { |
339 | 339 | return \imap_mime_header_decode($text); |
340 | 340 | } |
341 | 341 | $charset = $this->getEncoding($text); |
342 | - return [(object)[ |
|
342 | + return [(object) [ |
|
343 | 343 | "charset" => $charset, |
344 | 344 | "text" => $this->convertEncoding($text, $charset) |
345 | 345 | ]]; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | try { |
394 | 394 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
395 | 395 | return iconv($from, $to, $str); |
396 | - } else { |
|
396 | + }else { |
|
397 | 397 | if (!$from) { |
398 | 398 | return mb_convert_encoding($str, $to); |
399 | 399 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | if (strstr($from, '-')) { |
404 | 404 | $from = str_replace('-', '', $from); |
405 | 405 | return $this->convertEncoding($str, $from, $to); |
406 | - } else { |
|
406 | + }else { |
|
407 | 407 | return $str; |
408 | 408 | } |
409 | 409 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | } |
425 | 425 | }elseif (property_exists($structure, 'charset')) { |
426 | 426 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
427 | - }elseif (is_string($structure) === true){ |
|
427 | + }elseif (is_string($structure) === true) { |
|
428 | 428 | return mb_detect_encoding($structure); |
429 | 429 | } |
430 | 430 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | if ($value !== null) { |
458 | 458 | $is_utf8_base = $this->is_uft8($value); |
459 | 459 | |
460 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
460 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
461 | 461 | $value = \imap_utf8($value); |
462 | 462 | $is_utf8_base = $this->is_uft8($value); |
463 | 463 | if ($is_utf8_base) { |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | if ($this->notDecoded($original_value, $value)) { |
467 | 467 | $decoded_value = $this->mime_header_decode($value); |
468 | 468 | if (count($decoded_value) > 0) { |
469 | - if(property_exists($decoded_value[0], "text")) { |
|
469 | + if (property_exists($decoded_value[0], "text")) { |
|
470 | 470 | $value = $decoded_value[0]->text; |
471 | 471 | } |
472 | 472 | } |
473 | 473 | } |
474 | - }elseif($decoder === 'iconv' && $is_utf8_base) { |
|
474 | + }elseif ($decoder === 'iconv' && $is_utf8_base) { |
|
475 | 475 | $value = iconv_mime_decode($value); |
476 | - }elseif($is_utf8_base){ |
|
476 | + }elseif ($is_utf8_base) { |
|
477 | 477 | $value = mb_decode_mimeheader($value); |
478 | 478 | } |
479 | 479 | |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | * @return array |
497 | 497 | */ |
498 | 498 | private function decodeArray($values) { |
499 | - foreach($values as $key => $value) { |
|
499 | + foreach ($values as $key => $value) { |
|
500 | 500 | $values[$key] = $this->decode($value); |
501 | 501 | } |
502 | 502 | return $values; |
@@ -506,8 +506,8 @@ discard block |
||
506 | 506 | * Try to extract the priority from a given raw header string |
507 | 507 | */ |
508 | 508 | private function findPriority() { |
509 | - if(($priority = $this->get("x_priority")) === null) return; |
|
510 | - switch((int)"$priority"){ |
|
509 | + if (($priority = $this->get("x_priority")) === null) return; |
|
510 | + switch ((int) "$priority") { |
|
511 | 511 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
512 | 512 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
513 | 513 | break; |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | if (isset($parsed_address['address'])) { |
547 | 547 | $mail_address = explode('@', $parsed_address['address']); |
548 | 548 | if (count($mail_address) == 2) { |
549 | - $addresses[] = (object)[ |
|
549 | + $addresses[] = (object) [ |
|
550 | 550 | "personal" => isset($parsed_address['display']) ? $parsed_address['display'] : '', |
551 | 551 | "mailbox" => $mail_address[0], |
552 | 552 | "host" => $mail_address[1], |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | return $addresses; |
560 | 560 | } |
561 | 561 | |
562 | - foreach($values as $address) { |
|
562 | + foreach ($values as $address) { |
|
563 | 563 | foreach (preg_split('/, (?=(?:[^"]*"[^"]*")*[^"]*$)/', $address) as $split_address) { |
564 | 564 | $split_address = trim(rtrim($split_address)); |
565 | 565 | |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $name = trim(rtrim($matches["name"])); |
575 | 575 | $email = trim(rtrim($matches["email"])); |
576 | 576 | list($mailbox, $host) = array_pad(explode("@", $email), 2, null); |
577 | - $addresses[] = (object)[ |
|
577 | + $addresses[] = (object) [ |
|
578 | 578 | "personal" => $name, |
579 | 579 | "mailbox" => $mailbox, |
580 | 580 | "host" => $host, |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | * @param object $header |
592 | 592 | */ |
593 | 593 | private function extractAddresses($header) { |
594 | - foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){ |
|
594 | + foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) { |
|
595 | 595 | if (property_exists($header, $key)) { |
596 | 596 | $this->set($key, $this->parseAddresses($header->$key)); |
597 | 597 | } |
@@ -622,10 +622,10 @@ discard block |
||
622 | 622 | } |
623 | 623 | if (!property_exists($address, 'personal')) { |
624 | 624 | $address->personal = false; |
625 | - } else { |
|
625 | + }else { |
|
626 | 626 | $personalParts = $this->mime_header_decode($address->personal); |
627 | 627 | |
628 | - if(is_array($personalParts)) { |
|
628 | + if (is_array($personalParts)) { |
|
629 | 629 | $address->personal = ''; |
630 | 630 | foreach ($personalParts as $p) { |
631 | 631 | $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p)); |
@@ -649,23 +649,23 @@ discard block |
||
649 | 649 | /** |
650 | 650 | * Search and extract potential header extensions |
651 | 651 | */ |
652 | - private function extractHeaderExtensions(){ |
|
652 | + private function extractHeaderExtensions() { |
|
653 | 653 | foreach ($this->attributes as $key => $value) { |
654 | 654 | if (is_array($value)) { |
655 | 655 | $value = implode(", ", $value); |
656 | - }else{ |
|
657 | - $value = (string)$value; |
|
656 | + }else { |
|
657 | + $value = (string) $value; |
|
658 | 658 | } |
659 | 659 | // Only parse strings and don't parse any attributes like the user-agent |
660 | 660 | if (in_array($key, ["user_agent"]) === false) { |
661 | - if (($pos = strpos($value, ";")) !== false){ |
|
661 | + if (($pos = strpos($value, ";")) !== false) { |
|
662 | 662 | $original = substr($value, 0, $pos); |
663 | 663 | $this->set($key, trim(rtrim($original)), true); |
664 | 664 | |
665 | 665 | // Get all potential extensions |
666 | 666 | $extensions = explode(";", substr($value, $pos + 1)); |
667 | - foreach($extensions as $extension) { |
|
668 | - if (($pos = strpos($extension, "=")) !== false){ |
|
667 | + foreach ($extensions as $extension) { |
|
668 | + if (($pos = strpos($extension, "=")) !== false) { |
|
669 | 669 | $key = substr($extension, 0, $pos); |
670 | 670 | $key = trim(rtrim(strtolower($key))); |
671 | 671 | |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | $parsed_date = null; |
709 | 709 | $date = $header->date; |
710 | 710 | |
711 | - if(preg_match('/\+0580/', $date)) { |
|
711 | + if (preg_match('/\+0580/', $date)) { |
|
712 | 712 | $date = str_replace('+0580', '+0530', $date); |
713 | 713 | } |
714 | 714 | |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | $date = trim(array_pop($array)); |
732 | 732 | break; |
733 | 733 | } |
734 | - try{ |
|
734 | + try { |
|
735 | 735 | $parsed_date = Carbon::parse($date); |
736 | 736 | } catch (\Exception $_e) { |
737 | 737 | $error_message = "Invalid message date. ID:".$this->get("message_id")." Date:".$header->date."/".$date; |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | if(strtolower(substr($method, 0, 3)) === 'get') { |
306 | 306 | $name = Str::snake(substr($method, 3)); |
307 | 307 | return $this->get($name); |
308 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
308 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
309 | 309 | $name = Str::snake(substr($method, 3)); |
310 | 310 | |
311 | 311 | if(in_array($name, array_keys($this->attributes))) { |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | if ($this->getFlags()->get("seen") == null) { |
512 | 512 | $this->unsetFlag("Seen"); |
513 | 513 | } |
514 | - }elseif ($this->getFlags()->get("seen") != null) { |
|
514 | + } elseif ($this->getFlags()->get("seen") != null) { |
|
515 | 515 | $this->setFlag("Seen"); |
516 | 516 | } |
517 | 517 | } |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | private function fetchPart(Part $part) { |
556 | 556 | if ($part->isAttachment()) { |
557 | 557 | $this->fetchAttachment($part); |
558 | - }else{ |
|
558 | + } else{ |
|
559 | 559 | $encoding = $this->getEncoding($part); |
560 | 560 | |
561 | 561 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | |
581 | 581 | if (isset($this->bodies[$subtype])) { |
582 | 582 | $this->bodies[$subtype] .= "\n".$content; |
583 | - }else{ |
|
583 | + } else{ |
|
584 | 584 | $this->bodies[$subtype] = $content; |
585 | 585 | } |
586 | 586 | } |
@@ -751,9 +751,9 @@ discard block |
||
751 | 751 | return EncodingAliases::get($parameter->value); |
752 | 752 | } |
753 | 753 | } |
754 | - }elseif (property_exists($structure, 'charset')){ |
|
754 | + } elseif (property_exists($structure, 'charset')){ |
|
755 | 755 | return EncodingAliases::get($structure->charset); |
756 | - }elseif (is_string($structure) === true){ |
|
756 | + } elseif (is_string($structure) === true){ |
|
757 | 757 | return mb_detect_encoding($structure); |
758 | 758 | } |
759 | 759 | |
@@ -937,13 +937,15 @@ discard block |
||
937 | 937 | * @throws MessageHeaderFetchingException |
938 | 938 | */ |
939 | 939 | protected function fetchNewMail($folder, $next_uid, $event, $expunge){ |
940 | - if($expunge) $this->client->expunge(); |
|
940 | + if($expunge) { |
|
941 | + $this->client->expunge(); |
|
942 | + } |
|
941 | 943 | |
942 | 944 | $this->client->openFolder($folder->path); |
943 | 945 | |
944 | 946 | if ($this->sequence === IMAP::ST_UID) { |
945 | 947 | $sequence_id = $next_uid; |
946 | - }else{ |
|
948 | + } else{ |
|
947 | 949 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
948 | 950 | } |
949 | 951 | |
@@ -966,7 +968,9 @@ discard block |
||
966 | 968 | */ |
967 | 969 | public function delete($expunge = true) { |
968 | 970 | $status = $this->setFlag("Deleted"); |
969 | - if($expunge) $this->client->expunge(); |
|
971 | + if($expunge) { |
|
972 | + $this->client->expunge(); |
|
973 | + } |
|
970 | 974 | |
971 | 975 | $event = $this->getEvent("message", "deleted"); |
972 | 976 | $event::dispatch($this); |
@@ -986,7 +990,9 @@ discard block |
||
986 | 990 | */ |
987 | 991 | public function restore($expunge = true) { |
988 | 992 | $status = $this->unsetFlag("Deleted"); |
989 | - if($expunge) $this->client->expunge(); |
|
993 | + if($expunge) { |
|
994 | + $this->client->expunge(); |
|
995 | + } |
|
990 | 996 | |
991 | 997 | $event = $this->getEvent("message", "restored"); |
992 | 998 | $event::dispatch($this); |
@@ -1405,7 +1411,7 @@ discard block |
||
1405 | 1411 | if ($this->getSequence() === IMAP::ST_UID) { |
1406 | 1412 | $this->setUid($uid); |
1407 | 1413 | $this->setMsglist($msglist); |
1408 | - }else{ |
|
1414 | + } else{ |
|
1409 | 1415 | $this->setMsgn($uid, $msglist); |
1410 | 1416 | } |
1411 | 1417 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $this->boot(); |
193 | 193 | |
194 | 194 | $default_mask = $client->getDefaultMessageMask(); |
195 | - if($default_mask != null) { |
|
195 | + if ($default_mask != null) { |
|
196 | 196 | $this->mask = $default_mask; |
197 | 197 | } |
198 | 198 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | * @throws Exceptions\RuntimeException |
247 | 247 | * @throws Exceptions\MessageNotFoundException |
248 | 248 | */ |
249 | - public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){ |
|
249 | + public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) { |
|
250 | 250 | $reflection = new ReflectionClass(self::class); |
251 | 251 | /** @var self $instance */ |
252 | 252 | $instance = $reflection->newInstanceWithoutConstructor(); |
253 | 253 | $instance->boot(); |
254 | 254 | |
255 | 255 | $default_mask = $client->getDefaultMessageMask(); |
256 | - if($default_mask != null) { |
|
256 | + if ($default_mask != null) { |
|
257 | 257 | $instance->setMask($default_mask); |
258 | 258 | } |
259 | 259 | $instance->setEvents([ |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | /** |
279 | 279 | * Boot a new instance |
280 | 280 | */ |
281 | - public function boot(){ |
|
281 | + public function boot() { |
|
282 | 282 | $this->attributes = []; |
283 | 283 | |
284 | 284 | $this->config = ClientManager::get('options'); |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * @throws MethodNotFoundException |
298 | 298 | */ |
299 | 299 | public function __call($method, $arguments) { |
300 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
300 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
301 | 301 | $name = Str::snake(substr($method, 3)); |
302 | 302 | return $this->get($name); |
303 | 303 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
304 | 304 | $name = Str::snake(substr($method, 3)); |
305 | 305 | |
306 | - if(in_array($name, array_keys($this->attributes))) { |
|
306 | + if (in_array($name, array_keys($this->attributes))) { |
|
307 | 307 | return $this->__set($name, array_pop($arguments)); |
308 | 308 | } |
309 | 309 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @return Attribute|mixed|null |
343 | 343 | */ |
344 | 344 | public function get($name) { |
345 | - if(isset($this->attributes[$name])) { |
|
345 | + if (isset($this->attributes[$name])) { |
|
346 | 346 | return $this->attributes[$name]; |
347 | 347 | } |
348 | 348 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * |
417 | 417 | * @throws InvalidMessageDateException |
418 | 418 | */ |
419 | - public function parseRawHeader($raw_header){ |
|
419 | + public function parseRawHeader($raw_header) { |
|
420 | 420 | $this->header = new Header($raw_header); |
421 | 421 | } |
422 | 422 | |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | public function parseRawFlags($raw_flags) { |
428 | 428 | $this->flags = FlagCollection::make([]); |
429 | 429 | |
430 | - foreach($raw_flags as $flag) { |
|
431 | - if (strpos($flag, "\\") === 0){ |
|
430 | + foreach ($raw_flags as $flag) { |
|
431 | + if (strpos($flag, "\\") === 0) { |
|
432 | 432 | $flag = substr($flag, 1); |
433 | 433 | } |
434 | 434 | $flag_key = strtolower($flag); |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @throws MessageFlagException |
502 | 502 | * @throws Exceptions\RuntimeException |
503 | 503 | */ |
504 | - public function peek(){ |
|
504 | + public function peek() { |
|
505 | 505 | if ($this->fetch_options == IMAP::FT_PEEK) { |
506 | 506 | if ($this->getFlags()->get("seen") == null) { |
507 | 507 | $this->unsetFlag("Seen"); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | private function fetchPart(Part $part) { |
551 | 551 | if ($part->isAttachment()) { |
552 | 552 | $this->fetchAttachment($part); |
553 | - }else{ |
|
553 | + }else { |
|
554 | 554 | $encoding = $this->getEncoding($part); |
555 | 555 | |
556 | 556 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | |
576 | 576 | if (isset($this->bodies[$subtype])) { |
577 | 577 | $this->bodies[$subtype] .= "\n".$content; |
578 | - }else{ |
|
578 | + }else { |
|
579 | 579 | $this->bodies[$subtype] = $content; |
580 | 580 | } |
581 | 581 | } |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) { |
592 | 592 | if ($oAttachment->getId() !== null) { |
593 | 593 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
594 | - } else { |
|
594 | + }else { |
|
595 | 595 | $this->attachments->push($oAttachment); |
596 | 596 | } |
597 | 597 | } |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | |
726 | 726 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
727 | 727 | return @iconv($from, $to.'//IGNORE', $str); |
728 | - } else { |
|
728 | + }else { |
|
729 | 729 | if (!$from) { |
730 | 730 | return mb_convert_encoding($str, $to); |
731 | 731 | } |
@@ -746,9 +746,9 @@ discard block |
||
746 | 746 | return EncodingAliases::get($parameter->value); |
747 | 747 | } |
748 | 748 | } |
749 | - }elseif (property_exists($structure, 'charset')){ |
|
749 | + }elseif (property_exists($structure, 'charset')) { |
|
750 | 750 | return EncodingAliases::get($structure->charset); |
751 | - }elseif (is_string($structure) === true){ |
|
751 | + }elseif (is_string($structure) === true) { |
|
752 | 752 | return mb_detect_encoding($structure); |
753 | 753 | } |
754 | 754 | |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | * @throws Exceptions\FolderFetchingException |
764 | 764 | * @throws Exceptions\RuntimeException |
765 | 765 | */ |
766 | - public function getFolder(){ |
|
766 | + public function getFolder() { |
|
767 | 767 | return $this->client->getFolderByPath($this->folder_path); |
768 | 768 | } |
769 | 769 | |
@@ -779,13 +779,13 @@ discard block |
||
779 | 779 | * @throws Exceptions\GetMessagesFailedException |
780 | 780 | * @throws Exceptions\RuntimeException |
781 | 781 | */ |
782 | - public function thread($sent_folder = null, &$thread = null, $folder = null){ |
|
782 | + public function thread($sent_folder = null, &$thread = null, $folder = null) { |
|
783 | 783 | $thread = $thread ? $thread : MessageCollection::make([]); |
784 | - $folder = $folder ? $folder : $this->getFolder(); |
|
784 | + $folder = $folder ? $folder : $this->getFolder(); |
|
785 | 785 | $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolderByPath(ClientManager::get("options.common_folders.sent", "INBOX/Sent")); |
786 | 786 | |
787 | 787 | /** @var Message $message */ |
788 | - foreach($thread as $message) { |
|
788 | + foreach ($thread as $message) { |
|
789 | 789 | if ($message->message_id->first() == $this->message_id->first()) { |
790 | 790 | return $thread; |
791 | 791 | } |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder); |
797 | 797 | |
798 | 798 | if (is_array($this->in_reply_to)) { |
799 | - foreach($this->in_reply_to as $in_reply_to) { |
|
799 | + foreach ($this->in_reply_to as $in_reply_to) { |
|
800 | 800 | $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder); |
801 | 801 | $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder); |
802 | 802 | } |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | * @throws Exceptions\GetMessagesFailedException |
818 | 818 | * @throws Exceptions\RuntimeException |
819 | 819 | */ |
820 | - protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){ |
|
820 | + protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder) { |
|
821 | 821 | $primary_folder->query()->inReplyTo($in_reply_to) |
822 | 822 | ->setFetchBody($this->getFetchBodyOption()) |
823 | 823 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | * @throws Exceptions\GetMessagesFailedException |
839 | 839 | * @throws Exceptions\RuntimeException |
840 | 840 | */ |
841 | - protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){ |
|
841 | + protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder) { |
|
842 | 842 | $primary_folder->query()->messageId($message_id) |
843 | 843 | ->setFetchBody($this->getFetchBodyOption()) |
844 | 844 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -934,14 +934,14 @@ discard block |
||
934 | 934 | * @throws MessageFlagException |
935 | 935 | * @throws MessageHeaderFetchingException |
936 | 936 | */ |
937 | - protected function fetchNewMail($folder, $next_uid, $event, $expunge){ |
|
938 | - if($expunge) $this->client->expunge(); |
|
937 | + protected function fetchNewMail($folder, $next_uid, $event, $expunge) { |
|
938 | + if ($expunge) $this->client->expunge(); |
|
939 | 939 | |
940 | 940 | $this->client->openFolder($folder->path); |
941 | 941 | |
942 | 942 | if ($this->sequence === IMAP::ST_UID) { |
943 | 943 | $sequence_id = $next_uid; |
944 | - }else{ |
|
944 | + }else { |
|
945 | 945 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
946 | 946 | } |
947 | 947 | |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | */ |
965 | 965 | public function delete($expunge = true) { |
966 | 966 | $status = $this->setFlag("Deleted"); |
967 | - if($expunge) $this->client->expunge(); |
|
967 | + if ($expunge) $this->client->expunge(); |
|
968 | 968 | |
969 | 969 | $event = $this->getEvent("message", "deleted"); |
970 | 970 | $event::dispatch($this); |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | */ |
985 | 985 | public function restore($expunge = true) { |
986 | 986 | $status = $this->unsetFlag("Deleted"); |
987 | - if($expunge) $this->client->expunge(); |
|
987 | + if ($expunge) $this->client->expunge(); |
|
988 | 988 | |
989 | 989 | $event = $this->getEvent("message", "restored"); |
990 | 990 | $event::dispatch($this); |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | * |
1090 | 1090 | * @return AttachmentCollection |
1091 | 1091 | */ |
1092 | - public function attachments(){ |
|
1092 | + public function attachments() { |
|
1093 | 1093 | return $this->getAttachments(); |
1094 | 1094 | } |
1095 | 1095 | |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | * |
1188 | 1188 | * @return FlagCollection |
1189 | 1189 | */ |
1190 | - public function flags(){ |
|
1190 | + public function flags() { |
|
1191 | 1191 | return $this->getFlags(); |
1192 | 1192 | } |
1193 | 1193 | |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | * |
1197 | 1197 | * @return Structure|null |
1198 | 1198 | */ |
1199 | - public function getStructure(){ |
|
1199 | + public function getStructure() { |
|
1200 | 1200 | return $this->structure; |
1201 | 1201 | } |
1202 | 1202 | |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | * |
1223 | 1223 | * @return array |
1224 | 1224 | */ |
1225 | - public function getAttributes(){ |
|
1225 | + public function getAttributes() { |
|
1226 | 1226 | return array_merge($this->attributes, $this->header->getAttributes()); |
1227 | 1227 | } |
1228 | 1228 | |
@@ -1232,8 +1232,8 @@ discard block |
||
1232 | 1232 | * |
1233 | 1233 | * @return $this |
1234 | 1234 | */ |
1235 | - public function setMask($mask){ |
|
1236 | - if(class_exists($mask)){ |
|
1235 | + public function setMask($mask) { |
|
1236 | + if (class_exists($mask)) { |
|
1237 | 1237 | $this->mask = $mask; |
1238 | 1238 | } |
1239 | 1239 | |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | * |
1246 | 1246 | * @return string |
1247 | 1247 | */ |
1248 | - public function getMask(){ |
|
1248 | + public function getMask() { |
|
1249 | 1249 | return $this->mask; |
1250 | 1250 | } |
1251 | 1251 | |
@@ -1256,9 +1256,9 @@ discard block |
||
1256 | 1256 | * @return mixed |
1257 | 1257 | * @throws MaskNotFoundException |
1258 | 1258 | */ |
1259 | - public function mask($mask = null){ |
|
1259 | + public function mask($mask = null) { |
|
1260 | 1260 | $mask = $mask !== null ? $mask : $this->mask; |
1261 | - if(class_exists($mask)){ |
|
1261 | + if (class_exists($mask)) { |
|
1262 | 1262 | return new $mask($this); |
1263 | 1263 | } |
1264 | 1264 | |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | * |
1271 | 1271 | * @return string |
1272 | 1272 | */ |
1273 | - public function getFolderPath(){ |
|
1273 | + public function getFolderPath() { |
|
1274 | 1274 | return $this->folder_path; |
1275 | 1275 | } |
1276 | 1276 | |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | * |
1281 | 1281 | * @return $this |
1282 | 1282 | */ |
1283 | - public function setFolderPath($folder_path){ |
|
1283 | + public function setFolderPath($folder_path) { |
|
1284 | 1284 | $this->folder_path = $folder_path; |
1285 | 1285 | |
1286 | 1286 | return $this; |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | * |
1293 | 1293 | * @return $this |
1294 | 1294 | */ |
1295 | - public function setConfig($config){ |
|
1295 | + public function setConfig($config) { |
|
1296 | 1296 | $this->config = $config; |
1297 | 1297 | |
1298 | 1298 | return $this; |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | * |
1305 | 1305 | * @return $this |
1306 | 1306 | */ |
1307 | - public function setAvailableFlags($available_flags){ |
|
1307 | + public function setAvailableFlags($available_flags) { |
|
1308 | 1308 | $this->available_flags = $available_flags; |
1309 | 1309 | |
1310 | 1310 | return $this; |
@@ -1316,7 +1316,7 @@ discard block |
||
1316 | 1316 | * |
1317 | 1317 | * @return $this |
1318 | 1318 | */ |
1319 | - public function setAttachments($attachments){ |
|
1319 | + public function setAttachments($attachments) { |
|
1320 | 1320 | $this->attachments = $attachments; |
1321 | 1321 | |
1322 | 1322 | return $this; |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | * |
1329 | 1329 | * @return $this |
1330 | 1330 | */ |
1331 | - public function setFlags($flags){ |
|
1331 | + public function setFlags($flags) { |
|
1332 | 1332 | $this->flags = $flags; |
1333 | 1333 | |
1334 | 1334 | return $this; |
@@ -1342,7 +1342,7 @@ discard block |
||
1342 | 1342 | * @throws Exceptions\RuntimeException |
1343 | 1343 | * @throws Exceptions\ConnectionFailedException |
1344 | 1344 | */ |
1345 | - public function setClient($client){ |
|
1345 | + public function setClient($client) { |
|
1346 | 1346 | $this->client = $client; |
1347 | 1347 | $this->client->openFolder($this->folder_path); |
1348 | 1348 | |
@@ -1357,7 +1357,7 @@ discard block |
||
1357 | 1357 | * @throws Exceptions\MessageNotFoundException |
1358 | 1358 | * @throws Exceptions\ConnectionFailedException |
1359 | 1359 | */ |
1360 | - public function setUid($uid){ |
|
1360 | + public function setUid($uid) { |
|
1361 | 1361 | $this->uid = $uid; |
1362 | 1362 | $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid); |
1363 | 1363 | $this->msglist = null; |
@@ -1374,7 +1374,7 @@ discard block |
||
1374 | 1374 | * @throws Exceptions\MessageNotFoundException |
1375 | 1375 | * @throws Exceptions\ConnectionFailedException |
1376 | 1376 | */ |
1377 | - public function setMsgn($msgn, $msglist = null){ |
|
1377 | + public function setMsgn($msgn, $msglist = null) { |
|
1378 | 1378 | $this->msgn = $msgn; |
1379 | 1379 | $this->msglist = $msglist; |
1380 | 1380 | $this->uid = $this->client->getConnection()->getUid($this->msgn); |
@@ -1387,7 +1387,7 @@ discard block |
||
1387 | 1387 | * |
1388 | 1388 | * @return int |
1389 | 1389 | */ |
1390 | - public function getSequence(){ |
|
1390 | + public function getSequence() { |
|
1391 | 1391 | return $this->sequence; |
1392 | 1392 | } |
1393 | 1393 | |
@@ -1396,7 +1396,7 @@ discard block |
||
1396 | 1396 | * |
1397 | 1397 | * @return int |
1398 | 1398 | */ |
1399 | - public function getSequenceId(){ |
|
1399 | + public function getSequenceId() { |
|
1400 | 1400 | return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn; |
1401 | 1401 | } |
1402 | 1402 | |
@@ -1408,11 +1408,11 @@ discard block |
||
1408 | 1408 | * @throws Exceptions\ConnectionFailedException |
1409 | 1409 | * @throws Exceptions\MessageNotFoundException |
1410 | 1410 | */ |
1411 | - public function setSequenceId($uid, $msglist = null){ |
|
1411 | + public function setSequenceId($uid, $msglist = null) { |
|
1412 | 1412 | if ($this->getSequence() === IMAP::ST_UID) { |
1413 | 1413 | $this->setUid($uid); |
1414 | 1414 | $this->setMsglist($msglist); |
1415 | - }else{ |
|
1415 | + }else { |
|
1416 | 1416 | $this->setMsgn($uid, $msglist); |
1417 | 1417 | } |
1418 | 1418 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws MessageContentFetchingException |
78 | 78 | * @throws InvalidMessageDateException |
79 | 79 | */ |
80 | - protected function parse(){ |
|
80 | + protected function parse() { |
|
81 | 81 | $this->findContentType(); |
82 | 82 | $this->parts = $this->find_parts(); |
83 | 83 | } |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Determine the message content type |
87 | 87 | */ |
88 | - public function findContentType(){ |
|
88 | + public function findContentType() { |
|
89 | 89 | $content_type = $this->header->get("content_type"); |
90 | 90 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
91 | - if(stripos($content_type, 'multipart') === 0) { |
|
91 | + if (stripos($content_type, 'multipart') === 0) { |
|
92 | 92 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
93 | - }else{ |
|
93 | + }else { |
|
94 | 94 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
95 | 95 | } |
96 | 96 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @return Part[] |
104 | 104 | * @throws InvalidMessageDateException |
105 | 105 | */ |
106 | - private function parsePart($context, $part_number = 0){ |
|
106 | + private function parsePart($context, $part_number = 0) { |
|
107 | 107 | $body = $context; |
108 | 108 | while (($pos = strpos($body, "\r\n")) > 0) { |
109 | 109 | $body = substr($body, $pos + 2); |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * @return array |
127 | 127 | * @throws InvalidMessageDateException |
128 | 128 | */ |
129 | - private function detectParts($boundary, $context, $part_number = 0){ |
|
130 | - $base_parts = explode( $boundary, $context); |
|
129 | + private function detectParts($boundary, $context, $part_number = 0) { |
|
130 | + $base_parts = explode($boundary, $context); |
|
131 | 131 | $final_parts = []; |
132 | - foreach($base_parts as $ctx) { |
|
132 | + foreach ($base_parts as $ctx) { |
|
133 | 133 | $ctx = substr($ctx, 2); |
134 | 134 | if ($ctx !== "--" && $ctx != "") { |
135 | 135 | $parts = $this->parsePart($ctx, $part_number); |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | * @throws MessageContentFetchingException |
151 | 151 | * @throws InvalidMessageDateException |
152 | 152 | */ |
153 | - public function find_parts(){ |
|
154 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
155 | - if (($boundary = $this->header->getBoundary()) === null) { |
|
153 | + public function find_parts() { |
|
154 | + if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
155 | + if (($boundary = $this->header->getBoundary()) === null) { |
|
156 | 156 | throw new MessageContentFetchingException("no content found", 0); |
157 | 157 | } |
158 | 158 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return string|null |
169 | 169 | * @Depricated since version 2.4.4 |
170 | 170 | */ |
171 | - public function getBoundary(){ |
|
171 | + public function getBoundary() { |
|
172 | 172 | return $this->header->getBoundary(); |
173 | 173 | } |
174 | 174 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
91 | 91 | if(stripos($content_type, 'multipart') === 0) { |
92 | 92 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
95 | 95 | } |
96 | 96 | } |
@@ -152,7 +152,9 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function orWhere(Closure $closure = null) { |
154 | 154 | $this->query->push(['OR']); |
155 | - if ($closure !== null) $closure($this); |
|
155 | + if ($closure !== null) { |
|
156 | + $closure($this); |
|
157 | + } |
|
156 | 158 | |
157 | 159 | return $this; |
158 | 160 | } |
@@ -164,7 +166,9 @@ discard block |
||
164 | 166 | */ |
165 | 167 | public function andWhere(Closure $closure = null) { |
166 | 168 | $this->query->push(['AND']); |
167 | - if ($closure !== null) $closure($this); |
|
169 | + if ($closure !== null) { |
|
170 | + $closure($this); |
|
171 | + } |
|
168 | 172 | |
169 | 173 | return $this; |
170 | 174 | } |
@@ -467,7 +467,6 @@ discard block |
||
467 | 467 | * @param mixed $value |
468 | 468 | * @param callable $callback |
469 | 469 | * @param callable|null $default |
470 | - |
|
471 | 470 | * @return $this|mixed |
472 | 471 | */ |
473 | 472 | public function when($value, $callback, $default = null) { |
@@ -487,7 +486,6 @@ discard block |
||
487 | 486 | * @param mixed $value |
488 | 487 | * @param callable $callback |
489 | 488 | * @param callable|null $default |
490 | - |
|
491 | 489 | * @return $this|mixed |
492 | 490 | */ |
493 | 491 | public function unless($value, $callback, $default = null) { |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | if (strpos(strtolower($name), "where") === false) { |
88 | - $method = 'where' . ucfirst($name); |
|
89 | - } else { |
|
88 | + $method = 'where'.ucfirst($name); |
|
89 | + }else { |
|
90 | 90 | $method = lcfirst($name); |
91 | 91 | } |
92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | return call_user_func_array([$that, $method], $arguments); |
95 | 95 | } |
96 | 96 | |
97 | - throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported'); |
|
97 | + throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | } |
132 | 132 | return $this->where($key, $value); |
133 | 133 | } |
134 | - } else { |
|
134 | + }else { |
|
135 | 135 | $criteria = $this->validate_criteria($criteria); |
136 | 136 | $value = $this->parse_value($value); |
137 | 137 | |
138 | 138 | if ($value === null || $value === '') { |
139 | 139 | $this->query->push([$criteria]); |
140 | - } else { |
|
140 | + }else { |
|
141 | 141 | $this->query->push([$criteria, $value]); |
142 | 142 | } |
143 | 143 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * @return $this|mixed |
492 | 492 | */ |
493 | 493 | public function unless($value, $callback, $default = null) { |
494 | - if (! $value) { |
|
494 | + if (!$value) { |
|
495 | 495 | return $callback($this, $value) ?: $this; |
496 | 496 | } elseif ($default) { |
497 | 497 | return $default($this, $value) ?: $this; |