@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | public function __construct(Client $client, $charset = 'UTF-8') { |
| 69 | 69 | $this->setClient($client); |
| 70 | 70 | |
| 71 | - if(config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 71 | + if (config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 72 | 72 | |
| 73 | 73 | $this->date_format = config('imap.date_format', 'd M y'); |
| 74 | 74 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | /** |
| 81 | 81 | * Instance boot method for additional functionality |
| 82 | 82 | */ |
| 83 | - protected function boot(){} |
|
| 83 | + protected function boot() {} |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Parse a given value |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return string |
| 90 | 90 | */ |
| 91 | - protected function parse_value($value){ |
|
| 92 | - switch(true){ |
|
| 91 | + protected function parse_value($value) { |
|
| 92 | + switch (true) { |
|
| 93 | 93 | case $value instanceof \Carbon\Carbon: |
| 94 | 94 | $value = $value->format($this->date_format); |
| 95 | 95 | break; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @throws MessageSearchValidationException |
| 107 | 107 | */ |
| 108 | 108 | protected function parse_date($date) { |
| 109 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 109 | + if ($date instanceof \Carbon\Carbon) return $date; |
|
| 110 | 110 | |
| 111 | 111 | try { |
| 112 | 112 | $date = Carbon::parse($date); |
@@ -145,16 +145,16 @@ discard block |
||
| 145 | 145 | * @return \Illuminate\Support\Collection |
| 146 | 146 | * @throws \Webklex\IMAP\Exceptions\ConnectionFailedException |
| 147 | 147 | */ |
| 148 | - protected function search(){ |
|
| 148 | + protected function search() { |
|
| 149 | 149 | $this->generate_query(); |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * Don't set the charset if it isn't used - prevent strange outlook mail server errors |
| 153 | 153 | * @see https://github.com/Webklex/laravel-imap/issues/100 |
| 154 | 154 | */ |
| 155 | - if($this->getCharset() === null){ |
|
| 155 | + if ($this->getCharset() === null) { |
|
| 156 | 156 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID); |
| 157 | - }else{ |
|
| 157 | + } else { |
|
| 158 | 158 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID, $this->getCharset()); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -194,15 +194,15 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | $options = config('imap.options'); |
| 196 | 196 | |
| 197 | - if(strtolower($options['fetch_order']) === 'desc'){ |
|
| 197 | + if (strtolower($options['fetch_order']) === 'desc') { |
|
| 198 | 198 | $available_messages = $available_messages->reverse(); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - $query =& $this; |
|
| 201 | + $query = & $this; |
|
| 202 | 202 | |
| 203 | 203 | $available_messages->forPage($this->page, $this->limit)->each(function($msgno, $msglist) use(&$messages, $options, $query) { |
| 204 | 204 | $oMessage = new Message($msgno, $msglist, $query->getClient(), $query->getFetchOptions(), $query->getFetchBody(), $query->getFetchAttachment(), $query->getFetchFlags()); |
| 205 | - switch ($options['message_key']){ |
|
| 205 | + switch ($options['message_key']) { |
|
| 206 | 206 | case 'number': |
| 207 | 207 | $message_key = $oMessage->getMessageNo(); |
| 208 | 208 | break; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @return \Illuminate\Pagination\LengthAwarePaginator |
| 234 | 234 | * @throws GetMessagesFailedException |
| 235 | 235 | */ |
| 236 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
| 236 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
| 237 | 237 | $this->page = $page > $this->page ? $page : $this->page; |
| 238 | 238 | $this->limit = $per_page; |
| 239 | 239 | |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | if (count($statement) == 1) { |
| 252 | 252 | $query .= $statement[0]; |
| 253 | 253 | } else { |
| 254 | - if($statement[1] === null){ |
|
| 254 | + if ($statement[1] === null) { |
|
| 255 | 255 | $query .= $statement[0]; |
| 256 | - }else{ |
|
| 256 | + } else { |
|
| 257 | 257 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 258 | 258 | } |
| 259 | 259 | } |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | * @return $this |
| 284 | 284 | */ |
| 285 | 285 | public function limit($limit, $page = 1) { |
| 286 | - if($page >= 1) $this->page = $page; |
|
| 286 | + if ($page >= 1) $this->page = $page; |
|
| 287 | 287 | $this->limit = $limit; |
| 288 | 288 | |
| 289 | 289 | return $this; |
@@ -68,7 +68,9 @@ discard block |
||
| 68 | 68 | public function __construct(Client $client, $charset = 'UTF-8') { |
| 69 | 69 | $this->setClient($client); |
| 70 | 70 | |
| 71 | - if(config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 71 | + if(config('imap.options.fetch') === IMAP::FT_PEEK) { |
|
| 72 | + $this->leaveUnread(); |
|
| 73 | + } |
|
| 72 | 74 | |
| 73 | 75 | $this->date_format = config('imap.date_format', 'd M y'); |
| 74 | 76 | |
@@ -106,7 +108,9 @@ discard block |
||
| 106 | 108 | * @throws MessageSearchValidationException |
| 107 | 109 | */ |
| 108 | 110 | protected function parse_date($date) { |
| 109 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 111 | + if($date instanceof \Carbon\Carbon) { |
|
| 112 | + return $date; |
|
| 113 | + } |
|
| 110 | 114 | |
| 111 | 115 | try { |
| 112 | 116 | $date = Carbon::parse($date); |
@@ -154,7 +158,7 @@ discard block |
||
| 154 | 158 | */ |
| 155 | 159 | if($this->getCharset() === null){ |
| 156 | 160 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID); |
| 157 | - }else{ |
|
| 161 | + } else{ |
|
| 158 | 162 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID, $this->getCharset()); |
| 159 | 163 | } |
| 160 | 164 | |
@@ -253,7 +257,7 @@ discard block |
||
| 253 | 257 | } else { |
| 254 | 258 | if($statement[1] === null){ |
| 255 | 259 | $query .= $statement[0]; |
| 256 | - }else{ |
|
| 260 | + } else{ |
|
| 257 | 261 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 258 | 262 | } |
| 259 | 263 | } |
@@ -283,7 +287,9 @@ discard block |
||
| 283 | 287 | * @return $this |
| 284 | 288 | */ |
| 285 | 289 | public function limit($limit, $page = 1) { |
| 286 | - if($page >= 1) $this->page = $page; |
|
| 290 | + if($page >= 1) { |
|
| 291 | + $this->page = $page; |
|
| 292 | + } |
|
| 287 | 293 | $this->limit = $limit; |
| 288 | 294 | |
| 289 | 295 | return $this; |
@@ -436,14 +436,14 @@ |
||
| 436 | 436 | return $status; |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - /** |
|
| 440 | - * Delete Folder |
|
| 441 | - * @param string $name |
|
| 442 | - * @param boolean $expunge |
|
| 443 | - * |
|
| 444 | - * @return bool |
|
| 445 | - * @throws ConnectionFailedException |
|
| 446 | - */ |
|
| 439 | + /** |
|
| 440 | + * Delete Folder |
|
| 441 | + * @param string $name |
|
| 442 | + * @param boolean $expunge |
|
| 443 | + * |
|
| 444 | + * @return bool |
|
| 445 | + * @throws ConnectionFailedException |
|
| 446 | + */ |
|
| 447 | 447 | public function deleteFolder($name, $expunge = true) { |
| 448 | 448 | $this->checkConnection(); |
| 449 | 449 | $status = \imap_deletemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name)); |
@@ -173,45 +173,45 @@ discard block |
||
| 173 | 173 | * @throws MaskNotFoundException |
| 174 | 174 | */ |
| 175 | 175 | protected function setMaskFromConfig($config) { |
| 176 | - $default_config = config("imap.masks"); |
|
| 176 | + $default_config = config("imap.masks"); |
|
| 177 | 177 | |
| 178 | - if(isset($config['masks'])){ |
|
| 179 | - if(isset($config['masks']['message'])) { |
|
| 180 | - if(class_exists($config['masks']['message'])) { |
|
| 178 | + if (isset($config['masks'])) { |
|
| 179 | + if (isset($config['masks']['message'])) { |
|
| 180 | + if (class_exists($config['masks']['message'])) { |
|
| 181 | 181 | $this->default_message_mask = $config['masks']['message']; |
| 182 | - }else{ |
|
| 182 | + } else { |
|
| 183 | 183 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
| 184 | 184 | } |
| 185 | - }else{ |
|
| 186 | - if(class_exists($default_config['message'])) { |
|
| 185 | + } else { |
|
| 186 | + if (class_exists($default_config['message'])) { |
|
| 187 | 187 | $this->default_message_mask = $default_config['message']; |
| 188 | - }else{ |
|
| 188 | + } else { |
|
| 189 | 189 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - if(isset($config['masks']['attachment'])) { |
|
| 193 | - if(class_exists($config['masks']['attachment'])) { |
|
| 192 | + if (isset($config['masks']['attachment'])) { |
|
| 193 | + if (class_exists($config['masks']['attachment'])) { |
|
| 194 | 194 | $this->default_message_mask = $config['masks']['attachment']; |
| 195 | - }else{ |
|
| 195 | + } else { |
|
| 196 | 196 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
| 197 | 197 | } |
| 198 | - }else{ |
|
| 199 | - if(class_exists($default_config['attachment'])) { |
|
| 198 | + } else { |
|
| 199 | + if (class_exists($default_config['attachment'])) { |
|
| 200 | 200 | $this->default_message_mask = $default_config['attachment']; |
| 201 | - }else{ |
|
| 201 | + } else { |
|
| 202 | 202 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | - }else{ |
|
| 206 | - if(class_exists($default_config['message'])) { |
|
| 205 | + } else { |
|
| 206 | + if (class_exists($default_config['message'])) { |
|
| 207 | 207 | $this->default_message_mask = $default_config['message']; |
| 208 | - }else{ |
|
| 208 | + } else { |
|
| 209 | 209 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - if(class_exists($default_config['attachment'])) { |
|
| 212 | + if (class_exists($default_config['attachment'])) { |
|
| 213 | 213 | $this->default_message_mask = $default_config['attachment']; |
| 214 | - }else{ |
|
| 214 | + } else { |
|
| 215 | 215 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
| 362 | 362 | |
| 363 | 363 | $items = \imap_getmailboxes($this->connection, $this->getAddress(), $pattern); |
| 364 | - if(is_array($items)){ |
|
| 364 | + if (is_array($items)) { |
|
| 365 | 365 | foreach ($items as $item) { |
| 366 | 366 | $folder = new Folder($this, $item); |
| 367 | 367 | |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | return $folders; |
| 379 | - }else{ |
|
| 379 | + } else { |
|
| 380 | 380 | throw new MailboxFetchingException($this->getLastError()); |
| 381 | 381 | } |
| 382 | 382 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | public function openFolder($folder_path, $attempts = 3) { |
| 393 | 393 | $this->checkConnection(); |
| 394 | 394 | |
| 395 | - if(property_exists($folder_path, 'path')) { |
|
| 395 | + if (property_exists($folder_path, 'path')) { |
|
| 396 | 396 | $folder_path = $folder_path->path; |
| 397 | 397 | } |
| 398 | 398 | |
@@ -413,8 +413,8 @@ discard block |
||
| 413 | 413 | */ |
| 414 | 414 | public function createFolder($name, $expunge = true) { |
| 415 | 415 | $this->checkConnection(); |
| 416 | - $status = \imap_createmailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name)); |
|
| 417 | - if($expunge) $this->expunge(); |
|
| 416 | + $status = \imap_createmailbox($this->getConnection(), $this->getAddress().\imap_utf7_encode($name)); |
|
| 417 | + if ($expunge) $this->expunge(); |
|
| 418 | 418 | |
| 419 | 419 | return $status; |
| 420 | 420 | } |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | */ |
| 431 | 431 | public function renameFolder($old_name, $new_name, $expunge = true) { |
| 432 | 432 | $this->checkConnection(); |
| 433 | - $status = \imap_renamemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($old_name), $this->getAddress() . \imap_utf7_encode($new_name)); |
|
| 434 | - if($expunge) $this->expunge(); |
|
| 433 | + $status = \imap_renamemailbox($this->getConnection(), $this->getAddress().\imap_utf7_encode($old_name), $this->getAddress().\imap_utf7_encode($new_name)); |
|
| 434 | + if ($expunge) $this->expunge(); |
|
| 435 | 435 | |
| 436 | 436 | return $status; |
| 437 | 437 | } |
@@ -446,8 +446,8 @@ discard block |
||
| 446 | 446 | */ |
| 447 | 447 | public function deleteFolder($name, $expunge = true) { |
| 448 | 448 | $this->checkConnection(); |
| 449 | - $status = \imap_deletemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name)); |
|
| 450 | - if($expunge) $this->expunge(); |
|
| 449 | + $status = \imap_deletemailbox($this->getConnection(), $this->getAddress().\imap_utf7_encode($name)); |
|
| 450 | + if ($expunge) $this->expunge(); |
|
| 451 | 451 | |
| 452 | 452 | return $status; |
| 453 | 453 | } |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | if (!$this->validate_cert) { |
| 542 | 542 | $address .= '/novalidate-cert'; |
| 543 | 543 | } |
| 544 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
| 544 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
| 545 | 545 | $address .= '/'.$this->encryption; |
| 546 | 546 | } elseif ($this->encryption === "starttls") { |
| 547 | 547 | $address .= '/tls'; |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | * @throws InvalidImapTimeoutTypeException |
| 665 | 665 | */ |
| 666 | 666 | public function setTimeout($type, $timeout) { |
| 667 | - if(0 <= $type && $type <= 4) { |
|
| 667 | + if (0 <= $type && $type <= 4) { |
|
| 668 | 668 | return \imap_timeout($type, $timeout); |
| 669 | 669 | } |
| 670 | 670 | |
@@ -678,8 +678,8 @@ discard block |
||
| 678 | 678 | * @return mixed |
| 679 | 679 | * @throws InvalidImapTimeoutTypeException |
| 680 | 680 | */ |
| 681 | - public function getTimeout($type){ |
|
| 682 | - if(0 <= $type && $type <= 4) { |
|
| 681 | + public function getTimeout($type) { |
|
| 682 | + if (0 <= $type && $type <= 4) { |
|
| 683 | 683 | return \imap_timeout($type); |
| 684 | 684 | } |
| 685 | 685 | |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | /** |
| 690 | 690 | * @return string |
| 691 | 691 | */ |
| 692 | - public function getDefaultMessageMask(){ |
|
| 692 | + public function getDefaultMessageMask() { |
|
| 693 | 693 | return $this->default_message_mask; |
| 694 | 694 | } |
| 695 | 695 | |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | * @throws MaskNotFoundException |
| 701 | 701 | */ |
| 702 | 702 | public function setDefaultMessageMask($mask) { |
| 703 | - if(class_exists($mask)) { |
|
| 703 | + if (class_exists($mask)) { |
|
| 704 | 704 | $this->default_message_mask = $mask; |
| 705 | 705 | |
| 706 | 706 | return $this; |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | /** |
| 713 | 713 | * @return string |
| 714 | 714 | */ |
| 715 | - public function getDefaultAttachmentMask(){ |
|
| 715 | + public function getDefaultAttachmentMask() { |
|
| 716 | 716 | return $this->default_attachment_mask; |
| 717 | 717 | } |
| 718 | 718 | |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | * @throws MaskNotFoundException |
| 724 | 724 | */ |
| 725 | 725 | public function setDefaultAttachmentMask($mask) { |
| 726 | - if(class_exists($mask)) { |
|
| 726 | + if (class_exists($mask)) { |
|
| 727 | 727 | $this->default_attachment_mask = $mask; |
| 728 | 728 | |
| 729 | 729 | return $this; |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | * |
| 738 | 738 | * @return Folder |
| 739 | 739 | */ |
| 740 | - public function getFolderPath(){ |
|
| 740 | + public function getFolderPath() { |
|
| 741 | 741 | return $this->active_folder; |
| 742 | 742 | } |
| 743 | 743 | } |
@@ -179,39 +179,39 @@ discard block |
||
| 179 | 179 | if(isset($config['masks']['message'])) { |
| 180 | 180 | if(class_exists($config['masks']['message'])) { |
| 181 | 181 | $this->default_message_mask = $config['masks']['message']; |
| 182 | - }else{ |
|
| 182 | + } else{ |
|
| 183 | 183 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
| 184 | 184 | } |
| 185 | - }else{ |
|
| 185 | + } else{ |
|
| 186 | 186 | if(class_exists($default_config['message'])) { |
| 187 | 187 | $this->default_message_mask = $default_config['message']; |
| 188 | - }else{ |
|
| 188 | + } else{ |
|
| 189 | 189 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | if(isset($config['masks']['attachment'])) { |
| 193 | 193 | if(class_exists($config['masks']['attachment'])) { |
| 194 | 194 | $this->default_message_mask = $config['masks']['attachment']; |
| 195 | - }else{ |
|
| 195 | + } else{ |
|
| 196 | 196 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
| 197 | 197 | } |
| 198 | - }else{ |
|
| 198 | + } else{ |
|
| 199 | 199 | if(class_exists($default_config['attachment'])) { |
| 200 | 200 | $this->default_message_mask = $default_config['attachment']; |
| 201 | - }else{ |
|
| 201 | + } else{ |
|
| 202 | 202 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | - }else{ |
|
| 205 | + } else{ |
|
| 206 | 206 | if(class_exists($default_config['message'])) { |
| 207 | 207 | $this->default_message_mask = $default_config['message']; |
| 208 | - }else{ |
|
| 208 | + } else{ |
|
| 209 | 209 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | if(class_exists($default_config['attachment'])) { |
| 213 | 213 | $this->default_message_mask = $default_config['attachment']; |
| 214 | - }else{ |
|
| 214 | + } else{ |
|
| 215 | 215 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | return $folders; |
| 379 | - }else{ |
|
| 379 | + } else{ |
|
| 380 | 380 | throw new MailboxFetchingException($this->getLastError()); |
| 381 | 381 | } |
| 382 | 382 | } |
@@ -414,7 +414,9 @@ discard block |
||
| 414 | 414 | public function createFolder($name, $expunge = true) { |
| 415 | 415 | $this->checkConnection(); |
| 416 | 416 | $status = \imap_createmailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name)); |
| 417 | - if($expunge) $this->expunge(); |
|
| 417 | + if($expunge) { |
|
| 418 | + $this->expunge(); |
|
| 419 | + } |
|
| 418 | 420 | |
| 419 | 421 | return $status; |
| 420 | 422 | } |
@@ -431,7 +433,9 @@ discard block |
||
| 431 | 433 | public function renameFolder($old_name, $new_name, $expunge = true) { |
| 432 | 434 | $this->checkConnection(); |
| 433 | 435 | $status = \imap_renamemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($old_name), $this->getAddress() . \imap_utf7_encode($new_name)); |
| 434 | - if($expunge) $this->expunge(); |
|
| 436 | + if($expunge) { |
|
| 437 | + $this->expunge(); |
|
| 438 | + } |
|
| 435 | 439 | |
| 436 | 440 | return $status; |
| 437 | 441 | } |
@@ -447,7 +451,9 @@ discard block |
||
| 447 | 451 | public function deleteFolder($name, $expunge = true) { |
| 448 | 452 | $this->checkConnection(); |
| 449 | 453 | $status = \imap_deletemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name)); |
| 450 | - if($expunge) $this->expunge(); |
|
| 454 | + if($expunge) { |
|
| 455 | + $this->expunge(); |
|
| 456 | + } |
|
| 451 | 457 | |
| 452 | 458 | return $status; |
| 453 | 459 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = false) { |
| 198 | 198 | |
| 199 | 199 | $default_mask = $client->getDefaultMessageMask(); |
| 200 | - if($default_mask != null) { |
|
| 200 | + if ($default_mask != null) { |
|
| 201 | 201 | $this->mask = $default_mask; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $this->msglist = $msglist; |
| 217 | 217 | $this->client = $client; |
| 218 | 218 | |
| 219 | - $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid; |
|
| 219 | + $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid; |
|
| 220 | 220 | $this->msgn = ($this->fetch_options == IMAP::FT_UID) ? \imap_msgno($this->client->getConnection(), $uid) : $uid; |
| 221 | 221 | |
| 222 | 222 | $this->parseHeader(); |
@@ -239,17 +239,17 @@ discard block |
||
| 239 | 239 | * @throws MethodNotFoundException |
| 240 | 240 | */ |
| 241 | 241 | public function __call($method, $arguments) { |
| 242 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 242 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 243 | 243 | $name = Str::snake(substr($method, 3)); |
| 244 | 244 | |
| 245 | - if(in_array($name, array_keys($this->attributes))) { |
|
| 245 | + if (in_array($name, array_keys($this->attributes))) { |
|
| 246 | 246 | return $this->attributes[$name]; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
| 250 | 250 | $name = Str::snake(substr($method, 3)); |
| 251 | 251 | |
| 252 | - if(in_array($name, array_keys($this->attributes))) { |
|
| 252 | + if (in_array($name, array_keys($this->attributes))) { |
|
| 253 | 253 | $this->attributes[$name] = array_pop($arguments); |
| 254 | 254 | |
| 255 | 255 | return $this->attributes[$name]; |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @return mixed|null |
| 279 | 279 | */ |
| 280 | 280 | public function __get($name) { |
| 281 | - if(isset($this->attributes[$name])) { |
|
| 281 | + if (isset($this->attributes[$name])) { |
|
| 282 | 282 | return $this->attributes[$name]; |
| 283 | 283 | } |
| 284 | 284 | |
@@ -364,11 +364,11 @@ discard block |
||
| 364 | 364 | if ($replaceImages !== false) { |
| 365 | 365 | $this->attachments->each(function($oAttachment) use(&$body, $replaceImages) { |
| 366 | 366 | /** @var Attachment $oAttachment */ |
| 367 | - if(is_callable($replaceImages)) { |
|
| 367 | + if (is_callable($replaceImages)) { |
|
| 368 | 368 | $body = $replaceImages($body, $oAttachment); |
| 369 | - }elseif(is_string($replaceImages)) { |
|
| 369 | + }elseif (is_string($replaceImages)) { |
|
| 370 | 370 | call_user_func($replaceImages, [$body, $oAttachment]); |
| 371 | - }else{ |
|
| 371 | + } else { |
|
| 372 | 372 | if ($oAttachment->id && $oAttachment->getImgSrc() != null) { |
| 373 | 373 | $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body); |
| 374 | 374 | } |
@@ -397,14 +397,14 @@ discard block |
||
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | if (property_exists($header, 'subject')) { |
| 400 | - if($this->config['decoder']['message']['subject'] === 'utf-8') { |
|
| 400 | + if ($this->config['decoder']['message']['subject'] === 'utf-8') { |
|
| 401 | 401 | $this->subject = \imap_utf8($header->subject); |
| 402 | - }else{ |
|
| 402 | + } else { |
|
| 403 | 403 | $this->subject = mb_decode_mimeheader($header->subject); |
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){ |
|
| 407 | + foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) { |
|
| 408 | 408 | $this->extractHeaderAddressPart($header, $part); |
| 409 | 409 | } |
| 410 | 410 | |
@@ -434,9 +434,9 @@ discard block |
||
| 434 | 434 | * @return int|null |
| 435 | 435 | */ |
| 436 | 436 | private function extractPriority($header) { |
| 437 | - if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){ |
|
| 437 | + if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) { |
|
| 438 | 438 | $priority = isset($priority[1]) ? (int) $priority[1] : 0; |
| 439 | - switch($priority){ |
|
| 439 | + switch ($priority) { |
|
| 440 | 440 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 441 | 441 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 442 | 442 | break; |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | if (property_exists($header, 'date')) { |
| 488 | 488 | $date = $header->date; |
| 489 | 489 | |
| 490 | - if(preg_match('/\+0580/', $date)) { |
|
| 490 | + if (preg_match('/\+0580/', $date)) { |
|
| 491 | 491 | $date = str_replace('+0580', '+0530', $date); |
| 492 | 492 | } |
| 493 | 493 | |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | $date = trim(array_pop($array)); |
| 511 | 511 | break; |
| 512 | 512 | } |
| 513 | - try{ |
|
| 513 | + try { |
|
| 514 | 514 | $parsed_date = Carbon::parse($date); |
| 515 | 515 | } catch (\Exception $_e) { |
| 516 | 516 | throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e); |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | $this->client->openFolder($this->folder_path); |
| 534 | 534 | $flags = \imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 535 | 535 | if (is_array($flags) && isset($flags[0])) { |
| 536 | - foreach($this->available_flags as $flag) { |
|
| 536 | + foreach ($this->available_flags as $flag) { |
|
| 537 | 537 | $this->parseFlag($flags, $flag); |
| 538 | 538 | } |
| 539 | 539 | } |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | } else { |
| 606 | 606 | $personalParts = \imap_mime_header_decode($address->personal); |
| 607 | 607 | |
| 608 | - if(is_array($personalParts)) { |
|
| 608 | + if (is_array($personalParts)) { |
|
| 609 | 609 | $address->personal = ''; |
| 610 | 610 | foreach ($personalParts as $p) { |
| 611 | 611 | $encoding = $this->getEncoding($p->text); |
@@ -633,12 +633,12 @@ discard block |
||
| 633 | 633 | $this->client->openFolder($this->folder_path); |
| 634 | 634 | $this->structure = \imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 635 | 635 | |
| 636 | - if(property_exists($this->structure, 'parts')){ |
|
| 636 | + if (property_exists($this->structure, 'parts')) { |
|
| 637 | 637 | $parts = $this->structure->parts; |
| 638 | 638 | |
| 639 | - foreach ($parts as $part) { |
|
| 640 | - foreach ($part->parameters as $parameter) { |
|
| 641 | - if($parameter->attribute == "charset") { |
|
| 639 | + foreach ($parts as $part) { |
|
| 640 | + foreach ($part->parameters as $parameter) { |
|
| 641 | + if ($parameter->attribute == "charset") { |
|
| 642 | 642 | $encoding = $parameter->value; |
| 643 | 643 | |
| 644 | 644 | $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding); |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | return EncodingAliases::get($parameter->value); |
| 918 | 918 | } |
| 919 | 919 | } |
| 920 | - }elseif (is_string($structure) === true){ |
|
| 920 | + }elseif (is_string($structure) === true) { |
|
| 921 | 921 | return mb_detect_encoding($structure); |
| 922 | 922 | } |
| 923 | 923 | |
@@ -967,7 +967,7 @@ discard block |
||
| 967 | 967 | return null; |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | - public function getFolder(){ |
|
| 970 | + public function getFolder() { |
|
| 971 | 971 | return $this->client->getFolder($this->folder_path); |
| 972 | 972 | } |
| 973 | 973 | |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | */ |
| 984 | 984 | public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) { |
| 985 | 985 | |
| 986 | - if($create_folder) $this->client->createFolder($mailbox, true); |
|
| 986 | + if ($create_folder) $this->client->createFolder($mailbox, true); |
|
| 987 | 987 | |
| 988 | 988 | $target_folder = $this->client->getFolder($mailbox); |
| 989 | 989 | $target_status = $target_folder->getStatus(IMAP::SA_ALL); |
@@ -991,8 +991,8 @@ discard block |
||
| 991 | 991 | $this->client->openFolder($this->folder_path); |
| 992 | 992 | $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID); |
| 993 | 993 | |
| 994 | - if($status === true){ |
|
| 995 | - if($expunge) $this->client->expunge(); |
|
| 994 | + if ($status === true) { |
|
| 995 | + if ($expunge) $this->client->expunge(); |
|
| 996 | 996 | $this->client->openFolder($target_folder->path); |
| 997 | 997 | |
| 998 | 998 | return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags); |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | $this->client->openFolder($this->folder_path); |
| 1013 | 1013 | |
| 1014 | 1014 | $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 1015 | - if($expunge) $this->client->expunge(); |
|
| 1015 | + if ($expunge) $this->client->expunge(); |
|
| 1016 | 1016 | |
| 1017 | 1017 | return $status; |
| 1018 | 1018 | } |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | $this->client->openFolder($this->folder_path); |
| 1029 | 1029 | |
| 1030 | 1030 | $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 1031 | - if($expunge) $this->client->expunge(); |
|
| 1031 | + if ($expunge) $this->client->expunge(); |
|
| 1032 | 1032 | |
| 1033 | 1033 | return $status; |
| 1034 | 1034 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | /** |
| 1159 | 1159 | * @return object|null |
| 1160 | 1160 | */ |
| 1161 | - public function getStructure(){ |
|
| 1161 | + public function getStructure() { |
|
| 1162 | 1162 | return $this->structure; |
| 1163 | 1163 | } |
| 1164 | 1164 | |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | /** |
| 1185 | 1185 | * @return array |
| 1186 | 1186 | */ |
| 1187 | - public function getAttributes(){ |
|
| 1187 | + public function getAttributes() { |
|
| 1188 | 1188 | return $this->attributes; |
| 1189 | 1189 | } |
| 1190 | 1190 | |
@@ -1192,8 +1192,8 @@ discard block |
||
| 1192 | 1192 | * @param $mask |
| 1193 | 1193 | * @return $this |
| 1194 | 1194 | */ |
| 1195 | - public function setMask($mask){ |
|
| 1196 | - if(class_exists($mask)){ |
|
| 1195 | + public function setMask($mask) { |
|
| 1196 | + if (class_exists($mask)) { |
|
| 1197 | 1197 | $this->mask = $mask; |
| 1198 | 1198 | } |
| 1199 | 1199 | |
@@ -1203,7 +1203,7 @@ discard block |
||
| 1203 | 1203 | /** |
| 1204 | 1204 | * @return string |
| 1205 | 1205 | */ |
| 1206 | - public function getMask(){ |
|
| 1206 | + public function getMask() { |
|
| 1207 | 1207 | return $this->mask; |
| 1208 | 1208 | } |
| 1209 | 1209 | |
@@ -1214,9 +1214,9 @@ discard block |
||
| 1214 | 1214 | * @return mixed |
| 1215 | 1215 | * @throws MaskNotFoundException |
| 1216 | 1216 | */ |
| 1217 | - public function mask($mask = null){ |
|
| 1217 | + public function mask($mask = null) { |
|
| 1218 | 1218 | $mask = $mask !== null ? $mask : $this->mask; |
| 1219 | - if(class_exists($mask)){ |
|
| 1219 | + if (class_exists($mask)) { |
|
| 1220 | 1220 | return new $mask($this); |
| 1221 | 1221 | } |
| 1222 | 1222 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | return $this->attributes[$name]; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 249 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 250 | 250 | $name = Str::snake(substr($method, 3)); |
| 251 | 251 | |
| 252 | 252 | if(in_array($name, array_keys($this->attributes))) { |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | /** @var Attachment $oAttachment */ |
| 367 | 367 | if(is_callable($replaceImages)) { |
| 368 | 368 | $body = $replaceImages($body, $oAttachment); |
| 369 | - }elseif(is_string($replaceImages)) { |
|
| 369 | + } elseif(is_string($replaceImages)) { |
|
| 370 | 370 | call_user_func($replaceImages, [$body, $oAttachment]); |
| 371 | - }else{ |
|
| 371 | + } else{ |
|
| 372 | 372 | if ($oAttachment->id && $oAttachment->getImgSrc() != null) { |
| 373 | 373 | $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body); |
| 374 | 374 | } |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | if (property_exists($header, 'subject')) { |
| 400 | 400 | if($this->config['decoder']['message']['subject'] === 'utf-8') { |
| 401 | 401 | $this->subject = \imap_utf8($header->subject); |
| 402 | - }else{ |
|
| 402 | + } else{ |
|
| 403 | 403 | $this->subject = mb_decode_mimeheader($header->subject); |
| 404 | 404 | } |
| 405 | 405 | } |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | return EncodingAliases::get($parameter->value); |
| 918 | 918 | } |
| 919 | 919 | } |
| 920 | - }elseif (is_string($structure) === true){ |
|
| 920 | + } elseif (is_string($structure) === true){ |
|
| 921 | 921 | return mb_detect_encoding($structure); |
| 922 | 922 | } |
| 923 | 923 | |
@@ -983,7 +983,9 @@ discard block |
||
| 983 | 983 | */ |
| 984 | 984 | public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) { |
| 985 | 985 | |
| 986 | - if($create_folder) $this->client->createFolder($mailbox, true); |
|
| 986 | + if($create_folder) { |
|
| 987 | + $this->client->createFolder($mailbox, true); |
|
| 988 | + } |
|
| 987 | 989 | |
| 988 | 990 | $target_folder = $this->client->getFolder($mailbox); |
| 989 | 991 | $target_status = $target_folder->getStatus(IMAP::SA_ALL); |
@@ -992,7 +994,9 @@ discard block |
||
| 992 | 994 | $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID); |
| 993 | 995 | |
| 994 | 996 | if($status === true){ |
| 995 | - if($expunge) $this->client->expunge(); |
|
| 997 | + if($expunge) { |
|
| 998 | + $this->client->expunge(); |
|
| 999 | + } |
|
| 996 | 1000 | $this->client->openFolder($target_folder->path); |
| 997 | 1001 | |
| 998 | 1002 | return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags); |
@@ -1012,7 +1016,9 @@ discard block |
||
| 1012 | 1016 | $this->client->openFolder($this->folder_path); |
| 1013 | 1017 | |
| 1014 | 1018 | $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 1015 | - if($expunge) $this->client->expunge(); |
|
| 1019 | + if($expunge) { |
|
| 1020 | + $this->client->expunge(); |
|
| 1021 | + } |
|
| 1016 | 1022 | |
| 1017 | 1023 | return $status; |
| 1018 | 1024 | } |
@@ -1028,7 +1034,9 @@ discard block |
||
| 1028 | 1034 | $this->client->openFolder($this->folder_path); |
| 1029 | 1035 | |
| 1030 | 1036 | $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 1031 | - if($expunge) $this->client->expunge(); |
|
| 1037 | + if($expunge) { |
|
| 1038 | + $this->client->expunge(); |
|
| 1039 | + } |
|
| 1032 | 1040 | |
| 1033 | 1041 | return $status; |
| 1034 | 1042 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $this->setDelimiter($structure->delimiter); |
| 121 | 121 | $this->path = $structure->name; |
| 122 | - $this->full_name = $this->decodeName($structure->name); |
|
| 122 | + $this->full_name = $this->decodeName($structure->name); |
|
| 123 | 123 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
| 124 | 124 | |
| 125 | 125 | $this->parseAttributes($structure->attributes); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @return WhereQuery |
| 133 | 133 | * @throws Exceptions\ConnectionFailedException |
| 134 | 134 | */ |
| 135 | - public function query($charset = 'UTF-8'){ |
|
| 135 | + public function query($charset = 'UTF-8') { |
|
| 136 | 136 | $this->getClient()->checkConnection(); |
| 137 | 137 | $this->getClient()->openFolder($this->path); |
| 138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @inheritdoc self::query($charset = 'UTF-8') |
| 144 | 144 | * @throws Exceptions\ConnectionFailedException |
| 145 | 145 | */ |
| 146 | - public function search($charset = 'UTF-8'){ |
|
| 146 | + public function search($charset = 'UTF-8') { |
|
| 147 | 147 | return $this->query($charset); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @inheritdoc self::query($charset = 'UTF-8') |
| 152 | 152 | * @throws Exceptions\ConnectionFailedException |
| 153 | 153 | */ |
| 154 | - public function messages($charset = 'UTF-8'){ |
|
| 154 | + public function messages($charset = 'UTF-8') { |
|
| 155 | 155 | return $this->query($charset); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @deprecated 1.2.1:2.0.0 No longer needed. Use Folder::query() instead |
| 317 | 317 | * @see Folder::query() |
| 318 | 318 | */ |
| 319 | - public function searchMessages(array $where, $fetch_options = null, $fetch_body = true, $fetch_attachment = true, $fetch_flags = true, $limit = null, $page = 1, $charset = "UTF-8") { |
|
| 319 | + public function searchMessages(array $where, $fetch_options = null, $fetch_body = true, $fetch_attachment = true, $fetch_flags = true, $limit = null, $page = 1, $charset = "UTF-8") { |
|
| 320 | 320 | $this->getClient()->checkConnection(); |
| 321 | 321 | |
| 322 | 322 | return $this->query($charset)->where($where)->setFetchOptions($fetch_options)->setFetchBody($fetch_body) |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | public function delete($expunge = true) { |
| 377 | 377 | $status = \imap_deletemailbox($this->client->getConnection(), $this->path); |
| 378 | - if($expunge) $this->client->expunge(); |
|
| 378 | + if ($expunge) $this->client->expunge(); |
|
| 379 | 379 | |
| 380 | 380 | return $status; |
| 381 | 381 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | */ |
| 393 | 393 | public function move($target_mailbox, $expunge = true) { |
| 394 | 394 | $status = \imap_renamemailbox($this->client->getConnection(), $this->path, $target_mailbox); |
| 395 | - if($expunge) $this->client->expunge(); |
|
| 395 | + if ($expunge) $this->client->expunge(); |
|
| 396 | 396 | |
| 397 | 397 | return $status; |
| 398 | 398 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | */ |
| 434 | 434 | |
| 435 | 435 | if ($internal_date != null) { |
| 436 | - if ($internal_date instanceof \Carbon\Carbon){ |
|
| 436 | + if ($internal_date instanceof \Carbon\Carbon) { |
|
| 437 | 437 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
| 438 | 438 | } |
| 439 | 439 | return \imap_append($this->client->getConnection(), $this->path, $message, $options, $internal_date); |
@@ -454,8 +454,8 @@ discard block |
||
| 454 | 454 | /** |
| 455 | 455 | * @param $delimiter |
| 456 | 456 | */ |
| 457 | - public function setDelimiter($delimiter){ |
|
| 458 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
| 457 | + public function setDelimiter($delimiter) { |
|
| 458 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
| 459 | 459 | $delimiter = config('imap.options.delimiter', '/'); |
| 460 | 460 | } |
| 461 | 461 | |
@@ -375,7 +375,9 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | public function delete($expunge = true) { |
| 377 | 377 | $status = \imap_deletemailbox($this->client->getConnection(), $this->path); |
| 378 | - if($expunge) $this->client->expunge(); |
|
| 378 | + if($expunge) { |
|
| 379 | + $this->client->expunge(); |
|
| 380 | + } |
|
| 379 | 381 | |
| 380 | 382 | return $status; |
| 381 | 383 | } |
@@ -392,7 +394,9 @@ discard block |
||
| 392 | 394 | */ |
| 393 | 395 | public function move($target_mailbox, $expunge = true) { |
| 394 | 396 | $status = \imap_renamemailbox($this->client->getConnection(), $this->path, $target_mailbox); |
| 395 | - if($expunge) $this->client->expunge(); |
|
| 397 | + if($expunge) { |
|
| 398 | + $this->client->expunge(); |
|
| 399 | + } |
|
| 396 | 400 | |
| 397 | 401 | return $status; |
| 398 | 402 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $this->part_number = ($part_number) ? $part_number : $this->part_number; |
| 99 | 99 | |
| 100 | 100 | $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask(); |
| 101 | - if($default_mask != null) { |
|
| 101 | + if ($default_mask != null) { |
|
| 102 | 102 | $this->mask = $default_mask; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -115,10 +115,10 @@ discard block |
||
| 115 | 115 | * @throws MethodNotFoundException |
| 116 | 116 | */ |
| 117 | 117 | public function __call($method, $arguments) { |
| 118 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 118 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 119 | 119 | $name = Str::snake(substr($method, 3)); |
| 120 | 120 | |
| 121 | - if(isset($this->attributes[$name])) { |
|
| 121 | + if (isset($this->attributes[$name])) { |
|
| 122 | 122 | return $this->attributes[$name]; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @return mixed|null |
| 153 | 153 | */ |
| 154 | 154 | public function __get($name) { |
| 155 | - if(isset($this->attributes[$name])) { |
|
| 155 | + if (isset($this->attributes[$name])) { |
|
| 156 | 156 | return $this->attributes[$name]; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -264,9 +264,9 @@ discard block |
||
| 264 | 264 | * @param $name |
| 265 | 265 | */ |
| 266 | 266 | public function setName($name) { |
| 267 | - if($this->config['decoder']['message']['subject'] === 'utf-8') { |
|
| 267 | + if ($this->config['decoder']['message']['subject'] === 'utf-8') { |
|
| 268 | 268 | $this->name = \imap_utf8($name); |
| 269 | - }else{ |
|
| 269 | + } else { |
|
| 270 | 270 | $this->name = mb_decode_mimeheader($name); |
| 271 | 271 | } |
| 272 | 272 | } |
@@ -286,28 +286,28 @@ discard block |
||
| 286 | 286 | /** |
| 287 | 287 | * @return string|null |
| 288 | 288 | */ |
| 289 | - public function getMimeType(){ |
|
| 289 | + public function getMimeType() { |
|
| 290 | 290 | return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE); |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
| 294 | 294 | * @return string|null |
| 295 | 295 | */ |
| 296 | - public function getExtension(){ |
|
| 296 | + public function getExtension() { |
|
| 297 | 297 | return ExtensionGuesser::getInstance()->guess($this->getMimeType()); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
| 301 | 301 | * @return array |
| 302 | 302 | */ |
| 303 | - public function getAttributes(){ |
|
| 303 | + public function getAttributes() { |
|
| 304 | 304 | return $this->attributes; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
| 308 | 308 | * @return Message |
| 309 | 309 | */ |
| 310 | - public function getMessage(){ |
|
| 310 | + public function getMessage() { |
|
| 311 | 311 | return $this->oMessage; |
| 312 | 312 | } |
| 313 | 313 | |
@@ -315,8 +315,8 @@ discard block |
||
| 315 | 315 | * @param $mask |
| 316 | 316 | * @return $this |
| 317 | 317 | */ |
| 318 | - public function setMask($mask){ |
|
| 319 | - if(class_exists($mask)){ |
|
| 318 | + public function setMask($mask) { |
|
| 319 | + if (class_exists($mask)) { |
|
| 320 | 320 | $this->mask = $mask; |
| 321 | 321 | } |
| 322 | 322 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | /** |
| 327 | 327 | * @return string |
| 328 | 328 | */ |
| 329 | - public function getMask(){ |
|
| 329 | + public function getMask() { |
|
| 330 | 330 | return $this->mask; |
| 331 | 331 | } |
| 332 | 332 | |
@@ -337,9 +337,9 @@ discard block |
||
| 337 | 337 | * @return mixed |
| 338 | 338 | * @throws MaskNotFoundException |
| 339 | 339 | */ |
| 340 | - public function mask($mask = null){ |
|
| 340 | + public function mask($mask = null) { |
|
| 341 | 341 | $mask = $mask !== null ? $mask : $this->mask; |
| 342 | - if(class_exists($mask)){ |
|
| 342 | + if (class_exists($mask)) { |
|
| 343 | 343 | return new $mask($this); |
| 344 | 344 | } |
| 345 | 345 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return null; |
| 126 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 126 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 127 | 127 | $name = Str::snake(substr($method, 3)); |
| 128 | 128 | |
| 129 | 129 | $this->attributes[$name] = array_pop($arguments); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | public function setName($name) { |
| 267 | 267 | if($this->config['decoder']['message']['subject'] === 'utf-8') { |
| 268 | 268 | $this->name = \imap_utf8($name); |
| 269 | - }else{ |
|
| 269 | + } else{ |
|
| 270 | 270 | $this->name = mb_decode_mimeheader($name); |
| 271 | 271 | } |
| 272 | 272 | } |