@@ -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 | } |
@@ -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 | } |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * @throws InvalidMessageDateException |
128 | 128 | */ |
129 | 129 | private function detectParts(string $boundary, string $context, int $part_number = 0): array { |
130 | - $base_parts = explode( $boundary, $context); |
|
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); |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * @throws InvalidMessageDateException |
152 | 152 | */ |
153 | 153 | public function find_parts(): array { |
154 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
155 | - if (($boundary = $this->header->getBoundary()) === null) { |
|
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 | } |
@@ -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 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $this->part_number = $part->part_number; |
104 | 104 | |
105 | 105 | $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask(); |
106 | - if($default_mask != null) { |
|
106 | + if ($default_mask != null) { |
|
107 | 107 | $this->mask = $default_mask; |
108 | 108 | } |
109 | 109 | |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | * @throws MethodNotFoundException |
121 | 121 | */ |
122 | 122 | public function __call(string $method, array $arguments) { |
123 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
123 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
124 | 124 | $name = Str::snake(substr($method, 3)); |
125 | 125 | |
126 | - if(isset($this->attributes[$name])) { |
|
126 | + if (isset($this->attributes[$name])) { |
|
127 | 127 | return $this->attributes[$name]; |
128 | 128 | } |
129 | 129 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @return mixed|null |
160 | 160 | */ |
161 | 161 | public function __get($name) { |
162 | - if(isset($this->attributes[$name])) { |
|
162 | + if (isset($this->attributes[$name])) { |
|
163 | 163 | return $this->attributes[$name]; |
164 | 164 | } |
165 | 165 | |
@@ -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 | /** @var \Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser $deprecated_guesser */ |
284 | 284 | return $deprecated_guesser::getInstance()->guess($this->getMimeType()); |
285 | 285 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @return $this |
313 | 313 | */ |
314 | 314 | public function setMask($mask): Attachment { |
315 | - if(class_exists($mask)){ |
|
315 | + if (class_exists($mask)) { |
|
316 | 316 | $this->mask = $mask; |
317 | 317 | } |
318 | 318 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * @return mixed |
336 | 336 | * @throws MaskNotFoundException |
337 | 337 | */ |
338 | - public function mask($mask = null){ |
|
338 | + public function mask($mask = null) { |
|
339 | 339 | $mask = $mask !== null ? $mask : $this->mask; |
340 | - if(class_exists($mask)){ |
|
340 | + if (class_exists($mask)) { |
|
341 | 341 | return new $mask($this); |
342 | 342 | } |
343 | 343 |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $value = $this->default_account_config[$key]; |
208 | 208 | if(isset($config[$key])) { |
209 | 209 | $value = $config[$key]; |
210 | - }elseif(isset($default_config[$key])) { |
|
210 | + } elseif(isset($default_config[$key])) { |
|
211 | 211 | $value = $default_config[$key]; |
212 | 212 | } |
213 | 213 | $this->$key = $value; |
@@ -239,39 +239,39 @@ discard block |
||
239 | 239 | if(isset($config['masks']['message'])) { |
240 | 240 | if(class_exists($config['masks']['message'])) { |
241 | 241 | $this->default_message_mask = $config['masks']['message']; |
242 | - }else{ |
|
242 | + } else{ |
|
243 | 243 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
244 | 244 | } |
245 | - }else{ |
|
245 | + } else{ |
|
246 | 246 | if(class_exists($default_config['message'])) { |
247 | 247 | $this->default_message_mask = $default_config['message']; |
248 | - }else{ |
|
248 | + } else{ |
|
249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
250 | 250 | } |
251 | 251 | } |
252 | 252 | if(isset($config['masks']['attachment'])) { |
253 | 253 | if(class_exists($config['masks']['attachment'])) { |
254 | 254 | $this->default_attachment_mask = $config['masks']['attachment']; |
255 | - }else{ |
|
255 | + } else{ |
|
256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
257 | 257 | } |
258 | - }else{ |
|
258 | + } else{ |
|
259 | 259 | if(class_exists($default_config['attachment'])) { |
260 | 260 | $this->default_attachment_mask = $default_config['attachment']; |
261 | - }else{ |
|
261 | + } else{ |
|
262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
263 | 263 | } |
264 | 264 | } |
265 | - }else{ |
|
265 | + } else{ |
|
266 | 266 | if(class_exists($default_config['message'])) { |
267 | 267 | $this->default_message_mask = $default_config['message']; |
268 | - }else{ |
|
268 | + } else{ |
|
269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
270 | 270 | } |
271 | 271 | |
272 | 272 | if(class_exists($default_config['attachment'])) { |
273 | 273 | $this->default_attachment_mask = $default_config['attachment']; |
274 | - }else{ |
|
274 | + } else{ |
|
275 | 275 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
276 | 276 | } |
277 | 277 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
336 | 336 | $this->connection->setConnectionTimeout($this->timeout); |
337 | 337 | $this->connection->setProxy($this->proxy); |
338 | - }else{ |
|
338 | + } else{ |
|
339 | 339 | if (extension_loaded('imap') === false) { |
340 | 340 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
341 | 341 | } |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | return $folders; |
478 | - }else{ |
|
478 | + } else{ |
|
479 | 479 | throw new FolderFetchingException("failed to fetch any folders"); |
480 | 480 | } |
481 | 481 | } |
@@ -513,7 +513,9 @@ discard block |
||
513 | 513 | $this->checkConnection(); |
514 | 514 | $status = $this->connection->createFolder($folder); |
515 | 515 | |
516 | - if($expunge) $this->expunge(); |
|
516 | + if($expunge) { |
|
517 | + $this->expunge(); |
|
518 | + } |
|
517 | 519 | |
518 | 520 | $folder = $this->getFolder($folder); |
519 | 521 | if($status && $folder) { |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | * @param array $config |
211 | 211 | * @param array $default_config |
212 | 212 | */ |
213 | - private function setAccountConfig(string $key, array $config, array $default_config){ |
|
213 | + private function setAccountConfig(string $key, array $config, array $default_config) { |
|
214 | 214 | $value = $this->default_account_config[$key]; |
215 | - if(isset($config[$key])) { |
|
215 | + if (isset($config[$key])) { |
|
216 | 216 | $value = $config[$key]; |
217 | - }elseif(isset($default_config[$key])) { |
|
217 | + }elseif (isset($default_config[$key])) { |
|
218 | 218 | $value = $default_config[$key]; |
219 | 219 | } |
220 | 220 | $this->$key = $value; |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function setEventsFromConfig($config) { |
228 | 228 | $this->events = ClientManager::get("events"); |
229 | - if(isset($config['events'])){ |
|
230 | - foreach($config['events'] as $section => $events) { |
|
229 | + if (isset($config['events'])) { |
|
230 | + foreach ($config['events'] as $section => $events) { |
|
231 | 231 | $this->events[$section] = array_merge($this->events[$section], $events); |
232 | 232 | } |
233 | 233 | } |
@@ -240,45 +240,45 @@ discard block |
||
240 | 240 | * @throws MaskNotFoundException |
241 | 241 | */ |
242 | 242 | protected function setMaskFromConfig($config) { |
243 | - $default_config = ClientManager::get("masks"); |
|
243 | + $default_config = ClientManager::get("masks"); |
|
244 | 244 | |
245 | - if(isset($config['masks'])){ |
|
246 | - if(isset($config['masks']['message'])) { |
|
247 | - if(class_exists($config['masks']['message'])) { |
|
245 | + if (isset($config['masks'])) { |
|
246 | + if (isset($config['masks']['message'])) { |
|
247 | + if (class_exists($config['masks']['message'])) { |
|
248 | 248 | $this->default_message_mask = $config['masks']['message']; |
249 | - }else{ |
|
249 | + }else { |
|
250 | 250 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
251 | 251 | } |
252 | - }else{ |
|
253 | - if(class_exists($default_config['message'])) { |
|
252 | + }else { |
|
253 | + if (class_exists($default_config['message'])) { |
|
254 | 254 | $this->default_message_mask = $default_config['message']; |
255 | - }else{ |
|
255 | + }else { |
|
256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
257 | 257 | } |
258 | 258 | } |
259 | - if(isset($config['masks']['attachment'])) { |
|
260 | - if(class_exists($config['masks']['attachment'])) { |
|
259 | + if (isset($config['masks']['attachment'])) { |
|
260 | + if (class_exists($config['masks']['attachment'])) { |
|
261 | 261 | $this->default_attachment_mask = $config['masks']['attachment']; |
262 | - }else{ |
|
262 | + }else { |
|
263 | 263 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
264 | 264 | } |
265 | - }else{ |
|
266 | - if(class_exists($default_config['attachment'])) { |
|
265 | + }else { |
|
266 | + if (class_exists($default_config['attachment'])) { |
|
267 | 267 | $this->default_attachment_mask = $default_config['attachment']; |
268 | - }else{ |
|
268 | + }else { |
|
269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
270 | 270 | } |
271 | 271 | } |
272 | - }else{ |
|
273 | - if(class_exists($default_config['message'])) { |
|
272 | + }else { |
|
273 | + if (class_exists($default_config['message'])) { |
|
274 | 274 | $this->default_message_mask = $default_config['message']; |
275 | - }else{ |
|
275 | + }else { |
|
276 | 276 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
277 | 277 | } |
278 | 278 | |
279 | - if(class_exists($default_config['attachment'])) { |
|
279 | + if (class_exists($default_config['attachment'])) { |
|
280 | 280 | $this->default_attachment_mask = $default_config['attachment']; |
281 | - }else{ |
|
281 | + }else { |
|
282 | 282 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
283 | 283 | } |
284 | 284 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
343 | 343 | $this->connection->setConnectionTimeout($this->timeout); |
344 | 344 | $this->connection->setProxy($this->proxy); |
345 | - }else{ |
|
345 | + }else { |
|
346 | 346 | if (extension_loaded('imap') === false) { |
347 | 347 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
348 | 348 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | |
424 | 424 | // Set delimiter to false to force selection via getFolderByName (maybe useful for uncommon folder names) |
425 | 425 | $delimiter = is_null($delimiter) ? ClientManager::get('options.delimiter', "/") : $delimiter; |
426 | - if (strpos($folder_name, (string)$delimiter) !== false) { |
|
426 | + if (strpos($folder_name, (string) $delimiter) !== false) { |
|
427 | 427 | return $this->getFolderByPath($folder_name); |
428 | 428 | } |
429 | 429 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
476 | 476 | $items = $this->connection->folders('', $pattern); |
477 | 477 | |
478 | - if(is_array($items)){ |
|
478 | + if (is_array($items)) { |
|
479 | 479 | foreach ($items as $folder_name => $item) { |
480 | 480 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
481 | 481 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | return $folders; |
493 | - }else{ |
|
493 | + }else { |
|
494 | 494 | throw new FolderFetchingException("failed to fetch any folders"); |
495 | 495 | } |
496 | 496 | } |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | $this->checkConnection(); |
529 | 529 | $status = $this->connection->createFolder($folder); |
530 | 530 | |
531 | - if($expunge) $this->expunge(); |
|
531 | + if ($expunge) $this->expunge(); |
|
532 | 532 | |
533 | 533 | $folder = $this->getFolder($folder); |
534 | - if($status && $folder) { |
|
534 | + if ($status && $folder) { |
|
535 | 535 | $event = $this->getEvent("folder", "new"); |
536 | 536 | $event::dispatch($folder); |
537 | 537 | } |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * |
558 | 558 | * @return string |
559 | 559 | */ |
560 | - public function getFolderPath(){ |
|
560 | + public function getFolderPath() { |
|
561 | 561 | return $this->active_folder; |
562 | 562 | } |
563 | 563 | |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * @throws MaskNotFoundException |
663 | 663 | */ |
664 | 664 | public function setDefaultMessageMask(string $mask): Client { |
665 | - if(class_exists($mask)) { |
|
665 | + if (class_exists($mask)) { |
|
666 | 666 | $this->default_message_mask = $mask; |
667 | 667 | |
668 | 668 | return $this; |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | * @throws MaskNotFoundException |
689 | 689 | */ |
690 | 690 | public function setDefaultAttachmentMask(string $mask): Client { |
691 | - if(class_exists($mask)) { |
|
691 | + if (class_exists($mask)) { |
|
692 | 692 | $this->default_attachment_mask = $mask; |
693 | 693 | |
694 | 694 | return $this; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $name = $this->decodeFolderName($item->name); |
324 | 324 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
325 | 325 | } |
326 | - }else{ |
|
326 | + } else{ |
|
327 | 327 | throw new RuntimeException(\imap_last_error()); |
328 | 328 | } |
329 | 329 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | |
348 | 348 | if ($mode == "+"){ |
349 | 349 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
350 | - }else{ |
|
350 | + } else{ |
|
351 | 351 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
352 | 352 | } |
353 | 353 |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | throw new AuthFailedException($message); |
90 | 90 | } |
91 | 91 | |
92 | - if(!$this->stream) { |
|
92 | + if (!$this->stream) { |
|
93 | 93 | $errors = \imap_errors(); |
94 | 94 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
95 | 95 | throw new AuthFailedException($message); |
96 | 96 | } |
97 | 97 | |
98 | 98 | $errors = \imap_errors(); |
99 | - if(is_array($errors)) { |
|
99 | + if (is_array($errors)) { |
|
100 | 100 | $status = $this->examineFolder(); |
101 | - if($status['exists'] !== 0) { |
|
101 | + if ($status['exists'] !== 0) { |
|
102 | 102 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
103 | 103 | throw new RuntimeException($message); |
104 | 104 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | if (!$this->cert_validation) { |
130 | 130 | $address .= '/novalidate-cert'; |
131 | 131 | } |
132 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
132 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
133 | 133 | $address .= '/'.$this->encryption; |
134 | 134 | } elseif ($this->encryption === "starttls") { |
135 | 135 | $address .= '/tls'; |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | $flags = []; |
258 | 258 | if (is_array($raw_flags) && isset($raw_flags[0])) { |
259 | 259 | $raw_flags = (array) $raw_flags[0]; |
260 | - foreach($raw_flags as $flag => $value) { |
|
261 | - if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){ |
|
260 | + foreach ($raw_flags as $flag => $value) { |
|
261 | + if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) { |
|
262 | 262 | $flags[] = "\\".ucfirst($flag); |
263 | 263 | } |
264 | 264 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | $overview = $this->overview("1:*"); |
285 | 285 | $uids = []; |
286 | - foreach($overview as $set){ |
|
286 | + foreach ($overview as $set) { |
|
287 | 287 | $uids[$set->msgno] = $set->uid; |
288 | 288 | } |
289 | 289 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @return array |
313 | 313 | */ |
314 | 314 | public function overview(string $sequence, $uid = IMAP::ST_UID): array { |
315 | - return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL); |
|
315 | + return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::ST_UID : IMAP::NIL); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | $result = []; |
328 | 328 | |
329 | 329 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
330 | - if(is_array($items)){ |
|
330 | + if (is_array($items)) { |
|
331 | 331 | foreach ($items as $item) { |
332 | 332 | $name = $this->decodeFolderName($item->name); |
333 | 333 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
334 | 334 | } |
335 | - }else{ |
|
335 | + }else { |
|
336 | 336 | throw new RuntimeException(\imap_last_error()); |
337 | 337 | } |
338 | 338 | |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | public function store(array $flags, int $from, $to = null, $mode = null, bool $silent = true, $uid = IMAP::ST_UID, $item = null) { |
356 | 356 | $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags); |
357 | 357 | |
358 | - if ($mode == "+"){ |
|
358 | + if ($mode == "+") { |
|
359 | 359 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
360 | - }else{ |
|
360 | + }else { |
|
361 | 361 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
362 | 362 | } |
363 | 363 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public function appendMessage(string $folder, string $message, $flags = null, $date = null): bool { |
381 | 381 | if ($date != null) { |
382 | - if ($date instanceof \Carbon\Carbon){ |
|
382 | + if ($date instanceof \Carbon\Carbon) { |
|
383 | 383 | $date = $date->format('d-M-Y H:i:s O'); |
384 | 384 | } |
385 | 385 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @return array|bool Tokens if operation successful, false if an error occurred |
412 | 412 | */ |
413 | 413 | public function copyManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) { |
414 | - foreach($messages as $msg) { |
|
414 | + foreach ($messages as $msg) { |
|
415 | 415 | if (!$this->copyMessage($folder, $msg, null, $uid)) { |
416 | 416 | return false; |
417 | 417 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * @return array|bool Tokens if operation successful, false if an error occurred |
444 | 444 | */ |
445 | 445 | public function moveManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) { |
446 | - foreach($messages as $msg) { |
|
446 | + foreach ($messages as $msg) { |
|
447 | 447 | if (!$this->moveMessage($folder, $msg, null, $uid)) { |
448 | 448 | return false; |
449 | 449 | } |
@@ -570,14 +570,14 @@ discard block |
||
570 | 570 | /** |
571 | 571 | * Enable the debug mode |
572 | 572 | */ |
573 | - public function enableDebug(){ |
|
573 | + public function enableDebug() { |
|
574 | 574 | $this->debug = true; |
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
578 | 578 | * Disable the debug mode |
579 | 579 | */ |
580 | - public function disableDebug(){ |
|
580 | + public function disableDebug() { |
|
581 | 581 | $this->debug = false; |
582 | 582 | } |
583 | 583 |
@@ -285,7 +285,9 @@ discard block |
||
285 | 285 | } |
286 | 286 | |
287 | 287 | foreach ($headers as $key => $values) { |
288 | - if (isset($imap_headers[$key])) continue; |
|
288 | + if (isset($imap_headers[$key])) { |
|
289 | + continue; |
|
290 | + } |
|
289 | 291 | $value = null; |
290 | 292 | switch ($key) { |
291 | 293 | case 'from': |
@@ -506,7 +508,9 @@ discard block |
||
506 | 508 | * Try to extract the priority from a given raw header string |
507 | 509 | */ |
508 | 510 | private function findPriority() { |
509 | - if (($priority = $this->get("x_priority")) === null) return; |
|
511 | + if (($priority = $this->get("x_priority")) === null) { |
|
512 | + return; |
|
513 | + } |
|
510 | 514 | switch ((int)"$priority") { |
511 | 515 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
512 | 516 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported'); |
|
94 | + throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -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])) { |
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 | 144 | } elseif (!$this->attributize) { |
145 | 145 | $this->attributes[$name] = $value; |
146 | - } else { |
|
146 | + }else { |
|
147 | 147 | $this->attributes[$name] = new Attribute($name, $value); |
148 | 148 | } |
149 | 149 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $headers = []; |
237 | 237 | $imap_headers = []; |
238 | 238 | if (extension_loaded('imap') && $this->config["rfc822"]) { |
239 | - $raw_imap_headers = (array)\imap_rfc822_parse_headers($this->raw); |
|
239 | + $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw); |
|
240 | 240 | foreach ($raw_imap_headers as $key => $values) { |
241 | 241 | $key = str_replace("-", "_", $key); |
242 | 242 | $imap_headers[$key] = $values; |
@@ -264,11 +264,11 @@ 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); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $value = trim(rtrim(substr($line, $pos + 1))); |
277 | 277 | if (isset($headers[$key])) { |
278 | 278 | $headers[$key][] = $value; |
279 | - } else { |
|
279 | + }else { |
|
280 | 280 | $headers[$key] = [$value]; |
281 | 281 | } |
282 | 282 | $prev_header = $key; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | case 'reply_to': |
296 | 296 | case 'sender': |
297 | 297 | $value = $this->decodeAddresses($values); |
298 | - $headers[$key . "address"] = implode(", ", $values); |
|
298 | + $headers[$key."address"] = implode(", ", $values); |
|
299 | 299 | break; |
300 | 300 | case 'subject': |
301 | 301 | $value = implode(" ", $values); |
@@ -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 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $headers[$key] = $value; |
324 | 324 | } |
325 | 325 | |
326 | - return (object)array_merge($headers, $imap_headers); |
|
326 | + return (object) array_merge($headers, $imap_headers); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | return is_array($result) ? $result : []; |
341 | 341 | } |
342 | 342 | $charset = $this->getEncoding($text); |
343 | - return [(object)[ |
|
343 | + return [(object) [ |
|
344 | 344 | "charset" => $charset, |
345 | 345 | "text" => $this->convertEncoding($text, $charset) |
346 | 346 | ]]; |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | try { |
395 | 395 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
396 | 396 | return iconv($from, $to, $str); |
397 | - } else { |
|
397 | + }else { |
|
398 | 398 | if (!$from) { |
399 | 399 | return mb_convert_encoding($str, $to); |
400 | 400 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | if (strstr($from, '-')) { |
405 | 405 | $from = str_replace('-', '', $from); |
406 | 406 | return $this->convertEncoding($str, $from, $to); |
407 | - } else { |
|
407 | + }else { |
|
408 | 408 | return $str; |
409 | 409 | } |
410 | 410 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | */ |
510 | 510 | private function findPriority() { |
511 | 511 | if (($priority = $this->get("x_priority")) === null) return; |
512 | - switch ((int)"$priority") { |
|
512 | + switch ((int) "$priority") { |
|
513 | 513 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
514 | 514 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
515 | 515 | break; |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | if (isset($parsed_address['address'])) { |
549 | 549 | $mail_address = explode('@', $parsed_address['address']); |
550 | 550 | if (count($mail_address) == 2) { |
551 | - $addresses[] = (object)[ |
|
551 | + $addresses[] = (object) [ |
|
552 | 552 | "personal" => $parsed_address['display'] ?? '', |
553 | 553 | "mailbox" => $mail_address[0], |
554 | 554 | "host" => $mail_address[1], |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $name = trim(rtrim($matches["name"])); |
577 | 577 | $email = trim(rtrim($matches["email"])); |
578 | 578 | list($mailbox, $host) = array_pad(explode("@", $email), 2, null); |
579 | - $addresses[] = (object)[ |
|
579 | + $addresses[] = (object) [ |
|
580 | 580 | "personal" => $name, |
581 | 581 | "mailbox" => $mailbox, |
582 | 582 | "host" => $host, |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | } |
615 | 615 | |
616 | 616 | foreach ($list as $item) { |
617 | - $address = (object)$item; |
|
617 | + $address = (object) $item; |
|
618 | 618 | |
619 | 619 | if (!property_exists($address, 'mailbox')) { |
620 | 620 | $address->mailbox = false; |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | } |
625 | 625 | if (!property_exists($address, 'personal')) { |
626 | 626 | $address->personal = false; |
627 | - } else { |
|
627 | + }else { |
|
628 | 628 | $personalParts = $this->mime_header_decode($address->personal); |
629 | 629 | |
630 | 630 | if (is_array($personalParts)) { |
@@ -639,8 +639,8 @@ discard block |
||
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
642 | - $address->mail = ($address->mailbox && $address->host) ? $address->mailbox . '@' . $address->host : false; |
|
643 | - $address->full = ($address->personal) ? $address->personal . ' <' . $address->mail . '>' : $address->mail; |
|
642 | + $address->mail = ($address->mailbox && $address->host) ? $address->mailbox.'@'.$address->host : false; |
|
643 | + $address->full = ($address->personal) ? $address->personal.' <'.$address->mail.'>' : $address->mail; |
|
644 | 644 | |
645 | 645 | $addresses[] = new Address($address); |
646 | 646 | } |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | foreach ($this->attributes as $key => $value) { |
656 | 656 | if (is_array($value)) { |
657 | 657 | $value = implode(", ", $value); |
658 | - } else { |
|
659 | - $value = (string)$value; |
|
658 | + }else { |
|
659 | + $value = (string) $value; |
|
660 | 660 | } |
661 | 661 | // Only parse strings and don't parse any attributes like the user-agent |
662 | 662 | if (($key == "user_agent") === false) { |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | |
716 | 716 | $date = trim(rtrim($date)); |
717 | 717 | try { |
718 | - if(strpos($date, ' ') !== false){ |
|
718 | + if (strpos($date, ' ') !== false) { |
|
719 | 719 | $date = str_replace(' ', ' ', $date); |
720 | 720 | } |
721 | 721 | $parsed_date = Carbon::parse($date); |
@@ -742,8 +742,8 @@ discard block |
||
742 | 742 | $parsed_date = Carbon::parse($date); |
743 | 743 | } catch (\Exception $_e) { |
744 | 744 | if (!isset($this->config["fallback_date"])) { |
745 | - throw new InvalidMessageDateException("Invalid message date. ID:" . $this->get("message_id") . " Date:" . $header->date . "/" . $date, 1100, $e); |
|
746 | - } else { |
|
745 | + throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id")." Date:".$header->date."/".$date, 1100, $e); |
|
746 | + }else { |
|
747 | 747 | $parsed_date = Carbon::parse($this->config["fallback_date"]); |
748 | 748 | } |
749 | 749 | } |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | if($value === null) { |
81 | 81 | if(isset(self::$config[$part])) { |
82 | 82 | $value = self::$config[$part]; |
83 | - }else{ |
|
83 | + } else{ |
|
84 | 84 | break; |
85 | 85 | } |
86 | - }else{ |
|
86 | + } else{ |
|
87 | 87 | if(isset($value[$part])) { |
88 | 88 | $value = $value[$part]; |
89 | - }else{ |
|
89 | + } else{ |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
@@ -230,15 +230,21 @@ discard block |
||
230 | 230 | |
231 | 231 | // From https://stackoverflow.com/a/173479 |
232 | 232 | $isAssoc = function(array $arr) { |
233 | - if (array() === $arr) return false; |
|
233 | + if (array() === $arr) { |
|
234 | + return false; |
|
235 | + } |
|
234 | 236 | return array_keys($arr) !== range(0, count($arr) - 1); |
235 | 237 | }; |
236 | 238 | |
237 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
239 | + if(!is_array($base)) { |
|
240 | + $base = empty($base) ? array() : array($base); |
|
241 | + } |
|
238 | 242 | |
239 | 243 | foreach($arrays as $append) { |
240 | 244 | |
241 | - if(!is_array($append)) $append = array($append); |
|
245 | + if(!is_array($append)) { |
|
246 | + $append = array($append); |
|
247 | + } |
|
242 | 248 | |
243 | 249 | foreach($append as $key => $value) { |
244 | 250 | |
@@ -262,7 +268,9 @@ discard block |
||
262 | 268 | // results in $resultConfig['dispositions'] = ['attachment', 'inline'] |
263 | 269 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $value); |
264 | 270 | } else if(is_numeric($key)) { |
265 | - if(!in_array($value, $base)) $base[] = $value; |
|
271 | + if(!in_array($value, $base)) { |
|
272 | + $base[] = $value; |
|
273 | + } |
|
266 | 274 | } else { |
267 | 275 | $base[$key] = $value; |
268 | 276 | } |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | public static function get(string $key, $default = null) { |
77 | 77 | $parts = explode('.', $key); |
78 | 78 | $value = null; |
79 | - foreach($parts as $part) { |
|
80 | - if($value === null) { |
|
81 | - if(isset(self::$config[$part])) { |
|
79 | + foreach ($parts as $part) { |
|
80 | + if ($value === null) { |
|
81 | + if (isset(self::$config[$part])) { |
|
82 | 82 | $value = self::$config[$part]; |
83 | - }else{ |
|
83 | + }else { |
|
84 | 84 | break; |
85 | 85 | } |
86 | - }else{ |
|
87 | - if(isset($value[$part])) { |
|
86 | + }else { |
|
87 | + if (isset($value[$part])) { |
|
88 | 88 | $value = $value[$part]; |
89 | - }else{ |
|
89 | + }else { |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function setConfig($config): ClientManager { |
177 | 177 | |
178 | - if(is_array($config) === false) { |
|
178 | + if (is_array($config) === false) { |
|
179 | 179 | $config = require $config; |
180 | 180 | } |
181 | 181 | |
@@ -185,17 +185,17 @@ discard block |
||
185 | 185 | $vendor_config = require $path; |
186 | 186 | $config = $this->array_merge_recursive_distinct($vendor_config, $config); |
187 | 187 | |
188 | - if(is_array($config)){ |
|
189 | - if(isset($config['default'])){ |
|
190 | - if(isset($config['accounts']) && $config['default']){ |
|
188 | + if (is_array($config)) { |
|
189 | + if (isset($config['default'])) { |
|
190 | + if (isset($config['accounts']) && $config['default']) { |
|
191 | 191 | |
192 | 192 | $default_config = $vendor_config['accounts']['default']; |
193 | - if(isset($config['accounts'][$config['default']])){ |
|
193 | + if (isset($config['accounts'][$config['default']])) { |
|
194 | 194 | $default_config = array_merge($default_config, $config['accounts'][$config['default']]); |
195 | 195 | } |
196 | 196 | |
197 | - if(is_array($config['accounts'])){ |
|
198 | - foreach($config['accounts'] as $account_key => $account){ |
|
197 | + if (is_array($config['accounts'])) { |
|
198 | + foreach ($config['accounts'] as $account_key => $account) { |
|
199 | 199 | $config['accounts'][$account_key] = array_merge($default_config, $account); |
200 | 200 | } |
201 | 201 | } |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | return array_keys($arr) !== range(0, count($arr) - 1); |
235 | 235 | }; |
236 | 236 | |
237 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
237 | + if (!is_array($base)) $base = empty($base) ? array() : array($base); |
|
238 | 238 | |
239 | - foreach($arrays as $append) { |
|
239 | + foreach ($arrays as $append) { |
|
240 | 240 | |
241 | - if(!is_array($append)) $append = array($append); |
|
241 | + if (!is_array($append)) $append = array($append); |
|
242 | 242 | |
243 | - foreach($append as $key => $value) { |
|
243 | + foreach ($append as $key => $value) { |
|
244 | 244 | |
245 | - if(!array_key_exists($key, $base) and !is_numeric($key)) { |
|
245 | + if (!array_key_exists($key, $base) and !is_numeric($key)) { |
|
246 | 246 | $base[$key] = $value; |
247 | 247 | continue; |
248 | 248 | } |
249 | 249 | |
250 | - if( |
|
250 | + if ( |
|
251 | 251 | ( |
252 | 252 | is_array($value) |
253 | 253 | && $isAssoc($value) |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | // else merging $baseConfig['dispositions'] = ['attachment', 'inline'] with $customConfig['dispositions'] = ['attachment'] |
262 | 262 | // results in $resultConfig['dispositions'] = ['attachment', 'inline'] |
263 | 263 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $value); |
264 | - } else if(is_numeric($key)) { |
|
265 | - if(!in_array($value, $base)) $base[] = $value; |
|
266 | - } else { |
|
264 | + }else if (is_numeric($key)) { |
|
265 | + if (!in_array($value, $base)) $base[] = $value; |
|
266 | + }else { |
|
267 | 267 | $base[$key] = $value; |
268 | 268 | } |
269 | 269 |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public function offsetSet($offset, $value) { |
116 | 116 | if (is_null($offset)) { |
117 | 117 | $this->values[] = $value; |
118 | - } else { |
|
118 | + }else { |
|
119 | 119 | $this->values[$offset] = $value; |
120 | 120 | } |
121 | 121 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | if ($this->contains($value) === false) { |
189 | 189 | $this->values[] = $value; |
190 | 190 | } |
191 | - }else{ |
|
191 | + }else { |
|
192 | 192 | $this->values[] = $value; |
193 | 193 | } |
194 | 194 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return mixed|null |
239 | 239 | */ |
240 | - public function first(){ |
|
240 | + public function first() { |
|
241 | 241 | if ($this->offsetExists(0)) { |
242 | 242 | return $this->values[0]; |
243 | 243 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return mixed|null |
251 | 251 | */ |
252 | - public function last(){ |
|
252 | + public function last() { |
|
253 | 253 | if (($cnt = $this->count()) > 0) { |
254 | 254 | return $this->values[$cnt - 1]; |
255 | 255 | } |
@@ -78,7 +78,9 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function toDate(): Carbon { |
80 | 80 | $date = $this->first(); |
81 | - if ($date instanceof Carbon) return $date; |
|
81 | + if ($date instanceof Carbon) { |
|
82 | + return $date; |
|
83 | + } |
|
82 | 84 | |
83 | 85 | return Carbon::parse($date); |
84 | 86 | } |
@@ -141,7 +143,7 @@ discard block |
||
141 | 143 | public function add($value, bool $strict = false): Attribute { |
142 | 144 | if (is_array($value)) { |
143 | 145 | return $this->merge($value, $strict); |
144 | - }elseif ($value !== null) { |
|
146 | + } elseif ($value !== null) { |
|
145 | 147 | $this->attach($value, $strict); |
146 | 148 | } |
147 | 149 | |
@@ -188,7 +190,7 @@ discard block |
||
188 | 190 | if ($this->contains($value) === false) { |
189 | 191 | $this->values[] = $value; |
190 | 192 | } |
191 | - }else{ |
|
193 | + } else{ |
|
192 | 194 | $this->values[] = $value; |
193 | 195 | } |
194 | 196 | } |
@@ -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 | /** |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | foreach ($criteria as $key => $value) { |
138 | 138 | if (is_numeric($key)) { |
139 | 139 | $this->where($value); |
140 | - }else{ |
|
140 | + }else { |
|
141 | 141 | $this->where($key, $value); |
142 | 142 | } |
143 | 143 | } |
144 | - } else { |
|
144 | + }else { |
|
145 | 145 | $this->push_search_criteria($criteria, $value); |
146 | 146 | } |
147 | 147 | |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @throws InvalidWhereQueryCriteriaException |
157 | 157 | */ |
158 | - protected function push_search_criteria(string $criteria, $value){ |
|
158 | + protected function push_search_criteria(string $criteria, $value) { |
|
159 | 159 | $criteria = $this->validate_criteria($criteria); |
160 | 160 | $value = $this->parse_value($value); |
161 | 161 | |
162 | 162 | if ($value === null || $value === '') { |
163 | 163 | $this->query->push([$criteria]); |
164 | - } else { |
|
164 | + }else { |
|
165 | 165 | $this->query->push([$criteria, $value]); |
166 | 166 | } |
167 | 167 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | foreach ($criteria as $key => $value) { |
138 | 138 | if (is_numeric($key)) { |
139 | 139 | $this->where($value); |
140 | - }else{ |
|
140 | + } else{ |
|
141 | 141 | $this->where($key, $value); |
142 | 142 | } |
143 | 143 | } |
@@ -173,7 +173,9 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function orWhere(Closure $closure = null): WhereQuery { |
175 | 175 | $this->query->push(['OR']); |
176 | - if ($closure !== null) $closure($this); |
|
176 | + if ($closure !== null) { |
|
177 | + $closure($this); |
|
178 | + } |
|
177 | 179 | |
178 | 180 | return $this; |
179 | 181 | } |
@@ -185,7 +187,9 @@ discard block |
||
185 | 187 | */ |
186 | 188 | public function andWhere(Closure $closure = null): WhereQuery { |
187 | 189 | $this->query->push(['AND']); |
188 | - if ($closure !== null) $closure($this); |
|
190 | + if ($closure !== null) { |
|
191 | + $closure($this); |
|
192 | + } |
|
189 | 193 | |
190 | 194 | return $this; |
191 | 195 | } |
@@ -91,7 +91,9 @@ discard block |
||
91 | 91 | $this->setClient($client); |
92 | 92 | |
93 | 93 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
94 | - if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
94 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
95 | + $this->leaveUnread(); |
|
96 | + } |
|
95 | 97 | |
96 | 98 | if (ClientManager::get('options.fetch_order') === 'desc') { |
97 | 99 | $this->fetch_order = 'desc'; |
@@ -137,7 +139,9 @@ discard block |
||
137 | 139 | * @throws MessageSearchValidationException |
138 | 140 | */ |
139 | 141 | protected function parse_date($date): Carbon { |
140 | - if ($date instanceof Carbon) return $date; |
|
142 | + if ($date instanceof Carbon) { |
|
143 | + return $date; |
|
144 | + } |
|
141 | 145 | |
142 | 146 | try { |
143 | 147 | $date = Carbon::parse($date); |
@@ -644,7 +648,9 @@ discard block |
||
644 | 648 | * @return $this |
645 | 649 | */ |
646 | 650 | public function limit(int $limit, int $page = 1): Query { |
647 | - if ($page >= 1) $this->page = $page; |
|
651 | + if ($page >= 1) { |
|
652 | + $this->page = $page; |
|
653 | + } |
|
648 | 654 | $this->limit = $limit; |
649 | 655 | |
650 | 656 | return $this; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | if (ClientManager::get('options.fetch_order') === 'desc') { |
97 | 97 | $this->fetch_order = 'desc'; |
98 | - } else { |
|
98 | + }else { |
|
99 | 99 | $this->fetch_order = 'asc'; |
100 | 100 | } |
101 | 101 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $value = $value->format($this->date_format); |
125 | 125 | } |
126 | 126 | |
127 | - return (string)$value; |
|
127 | + return (string) $value; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -156,14 +156,14 @@ discard block |
||
156 | 156 | $this->query->each(function($statement) use (&$query) { |
157 | 157 | if (count($statement) == 1) { |
158 | 158 | $query .= $statement[0]; |
159 | - } else { |
|
159 | + }else { |
|
160 | 160 | if ($statement[1] === null) { |
161 | 161 | $query .= $statement[0]; |
162 | - } else { |
|
162 | + }else { |
|
163 | 163 | if (is_numeric($statement[1])) { |
164 | - $query .= $statement[0] . ' ' . $statement[1]; |
|
165 | - } else { |
|
166 | - $query .= $statement[0] . ' "' . $statement[1] . '"'; |
|
164 | + $query .= $statement[0].' '.$statement[1]; |
|
165 | + }else { |
|
166 | + $query .= $statement[0].' "'.$statement[1].'"'; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $key = $message->getMessageId(); |
298 | 298 | break; |
299 | 299 | } |
300 | - return (string)$key; |
|
300 | + return (string) $key; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $extensions = $raw_messages["extensions"][$uid] ?? []; |
346 | 346 | |
347 | 347 | $message = $this->make($uid, $msglist, $header, $content, $flag); |
348 | - foreach($extensions as $key => $extension) { |
|
348 | + foreach ($extensions as $key => $extension) { |
|
349 | 349 | $message->getHeader()->set($key, $extension); |
350 | 350 | } |
351 | 351 | if ($message !== null) { |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | $uids = $connection->getUid(); |
498 | 498 | $available_messages = new Collection(); |
499 | 499 | if (is_array($uids)) { |
500 | - foreach ($uids as $id){ |
|
500 | + foreach ($uids as $id) { |
|
501 | 501 | if ($closure($id)) { |
502 | 502 | $available_messages->push($id); |
503 | 503 | } |