@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | public function __construct($parent) { |
| 44 | 44 | $this->parent = $parent; |
| 45 | 45 | |
| 46 | - if(method_exists($this->parent, 'getAttributes')){ |
|
| 46 | + if (method_exists($this->parent, 'getAttributes')) { |
|
| 47 | 47 | $this->attributes = array_merge($this->attributes, $this->parent->getAttributes()); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * Boot method made to be used by any custom mask |
| 55 | 55 | */ |
| 56 | - protected function boot(){} |
|
| 56 | + protected function boot() {} |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * Call dynamic attribute setter and getter methods and inherit the parent calls |
@@ -64,17 +64,17 @@ discard block |
||
| 64 | 64 | * @throws MethodNotFoundException |
| 65 | 65 | */ |
| 66 | 66 | public function __call($method, $arguments) { |
| 67 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 67 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 68 | 68 | $name = Str::snake(substr($method, 3)); |
| 69 | 69 | |
| 70 | - if(isset($this->attributes[$name])) { |
|
| 70 | + if (isset($this->attributes[$name])) { |
|
| 71 | 71 | return $this->attributes[$name]; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
| 75 | 75 | $name = Str::snake(substr($method, 3)); |
| 76 | 76 | |
| 77 | - if(isset($this->attributes[$name])) { |
|
| 77 | + if (isset($this->attributes[$name])) { |
|
| 78 | 78 | $this->attributes[$name] = array_pop($arguments); |
| 79 | 79 | |
| 80 | 80 | return $this->attributes[$name]; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if(method_exists($this->parent, $method) === true){ |
|
| 85 | + if (method_exists($this->parent, $method) === true) { |
|
| 86 | 86 | return call_user_func_array([$this->parent, $method], $arguments); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @return mixed|null |
| 110 | 110 | */ |
| 111 | 111 | public function __get($name) { |
| 112 | - if(isset($this->attributes[$name])) { |
|
| 112 | + if (isset($this->attributes[$name])) { |
|
| 113 | 113 | return $this->attributes[$name]; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @return mixed |
| 123 | 123 | */ |
| 124 | - public function getParent(){ |
|
| 124 | + public function getParent() { |
|
| 125 | 125 | return $this->parent; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @return array |
| 132 | 132 | */ |
| 133 | - public function getAttributes(){ |
|
| 133 | + public function getAttributes() { |
|
| 134 | 134 | return $this->attributes; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | $this->setDelimiter($delimiter); |
| 127 | 127 | $this->path = $folder_name; |
| 128 | - $this->full_name = $this->decodeName($folder_name); |
|
| 128 | + $this->full_name = $this->decodeName($folder_name); |
|
| 129 | 129 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
| 130 | 130 | |
| 131 | 131 | $this->parseAttributes($attributes); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @return WhereQuery |
| 139 | 139 | * @throws Exceptions\ConnectionFailedException |
| 140 | 140 | */ |
| 141 | - public function query($charset = 'UTF-8'){ |
|
| 141 | + public function query($charset = 'UTF-8') { |
|
| 142 | 142 | $this->getClient()->checkConnection(); |
| 143 | 143 | $this->getClient()->openFolder($this->path); |
| 144 | 144 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @inheritdoc self::query($charset = 'UTF-8') |
| 150 | 150 | * @throws Exceptions\ConnectionFailedException |
| 151 | 151 | */ |
| 152 | - public function search($charset = 'UTF-8'){ |
|
| 152 | + public function search($charset = 'UTF-8') { |
|
| 153 | 153 | return $this->query($charset); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @inheritdoc self::query($charset = 'UTF-8') |
| 158 | 158 | * @throws Exceptions\ConnectionFailedException |
| 159 | 159 | */ |
| 160 | - public function messages($charset = 'UTF-8'){ |
|
| 160 | + public function messages($charset = 'UTF-8') { |
|
| 161 | 161 | return $this->query($charset); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | public function move($new_name, $expunge = true) { |
| 233 | 233 | $this->client->checkConnection(); |
| 234 | 234 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
| 235 | - if($expunge) $this->client->expunge(); |
|
| 235 | + if ($expunge) $this->client->expunge(); |
|
| 236 | 236 | |
| 237 | 237 | $folder = $this->client->getFolder($new_name); |
| 238 | 238 | $event = $this->getEvent("folder", "moved"); |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | |
| 261 | 261 | if ($internal_date != null) { |
| 262 | - if ($internal_date instanceof Carbon){ |
|
| 262 | + if ($internal_date instanceof Carbon) { |
|
| 263 | 263 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function delete($expunge = true) { |
| 295 | 295 | $status = $this->client->getConnection()->deleteFolder($this->path); |
| 296 | - if($expunge) $this->client->expunge(); |
|
| 296 | + if ($expunge) $this->client->expunge(); |
|
| 297 | 297 | |
| 298 | 298 | $event = $this->getEvent("folder", "deleted"); |
| 299 | 299 | $event::dispatch($this); |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | try { |
| 349 | 349 | $line = $connection->nextLine(); |
| 350 | 350 | if (($pos = strpos($line, "EXISTS")) !== false) { |
| 351 | - $msgn = (int) substr($line, 2, $pos -2); |
|
| 351 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
| 352 | 352 | $connection->done(); |
| 353 | 353 | |
| 354 | 354 | $message = $this->query()->getMessage($msgn); |
@@ -359,10 +359,10 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | $connection->idle(); |
| 361 | 361 | } |
| 362 | - }catch (Exceptions\RuntimeException $e) { |
|
| 363 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
| 362 | + } catch (Exceptions\RuntimeException $e) { |
|
| 363 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
| 364 | 364 | throw $e; |
| 365 | - }else{ |
|
| 365 | + }else { |
|
| 366 | 366 | $this->client->connect(); |
| 367 | 367 | $this->client->openFolder($this->path); |
| 368 | 368 | $connection = $this->client->getConnection(); |
@@ -407,8 +407,8 @@ discard block |
||
| 407 | 407 | * Set the delimiter |
| 408 | 408 | * @param $delimiter |
| 409 | 409 | */ |
| 410 | - public function setDelimiter($delimiter){ |
|
| 411 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
| 410 | + public function setDelimiter($delimiter) { |
|
| 411 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
| 412 | 412 | $delimiter = ClientManager::get('options.delimiter', '/'); |
| 413 | 413 | } |
| 414 | 414 | |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | * @param array $config |
| 177 | 177 | * @param array $default_config |
| 178 | 178 | */ |
| 179 | - private function setAccountConfig($key, $config, $default_config){ |
|
| 179 | + private function setAccountConfig($key, $config, $default_config) { |
|
| 180 | 180 | $value = $this->default_account_config[$key]; |
| 181 | - if(isset($config[$key])) { |
|
| 181 | + if (isset($config[$key])) { |
|
| 182 | 182 | $value = $config[$key]; |
| 183 | - }elseif(isset($default_config[$key])) { |
|
| 183 | + }elseif (isset($default_config[$key])) { |
|
| 184 | 184 | $value = $default_config[$key]; |
| 185 | 185 | } |
| 186 | 186 | $this->$key = $value; |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | protected function setEventsFromConfig($config) { |
| 194 | 194 | $this->events = ClientManager::get("events"); |
| 195 | - if(isset($config['events'])){ |
|
| 196 | - if(isset($config['events'])) { |
|
| 197 | - foreach($config['events'] as $section => $events) { |
|
| 195 | + if (isset($config['events'])) { |
|
| 196 | + if (isset($config['events'])) { |
|
| 197 | + foreach ($config['events'] as $section => $events) { |
|
| 198 | 198 | $this->events[$section] = array_merge($this->events[$section], $events); |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -208,45 +208,45 @@ discard block |
||
| 208 | 208 | * @throws MaskNotFoundException |
| 209 | 209 | */ |
| 210 | 210 | protected function setMaskFromConfig($config) { |
| 211 | - $default_config = ClientManager::get("masks"); |
|
| 211 | + $default_config = ClientManager::get("masks"); |
|
| 212 | 212 | |
| 213 | - if(isset($config['masks'])){ |
|
| 214 | - if(isset($config['masks']['message'])) { |
|
| 215 | - if(class_exists($config['masks']['message'])) { |
|
| 213 | + if (isset($config['masks'])) { |
|
| 214 | + if (isset($config['masks']['message'])) { |
|
| 215 | + if (class_exists($config['masks']['message'])) { |
|
| 216 | 216 | $this->default_message_mask = $config['masks']['message']; |
| 217 | - }else{ |
|
| 217 | + }else { |
|
| 218 | 218 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
| 219 | 219 | } |
| 220 | - }else{ |
|
| 221 | - if(class_exists($default_config['message'])) { |
|
| 220 | + }else { |
|
| 221 | + if (class_exists($default_config['message'])) { |
|
| 222 | 222 | $this->default_message_mask = $default_config['message']; |
| 223 | - }else{ |
|
| 223 | + }else { |
|
| 224 | 224 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | - if(isset($config['masks']['attachment'])) { |
|
| 228 | - if(class_exists($config['masks']['attachment'])) { |
|
| 227 | + if (isset($config['masks']['attachment'])) { |
|
| 228 | + if (class_exists($config['masks']['attachment'])) { |
|
| 229 | 229 | $this->default_message_mask = $config['masks']['attachment']; |
| 230 | - }else{ |
|
| 230 | + }else { |
|
| 231 | 231 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
| 232 | 232 | } |
| 233 | - }else{ |
|
| 234 | - if(class_exists($default_config['attachment'])) { |
|
| 233 | + }else { |
|
| 234 | + if (class_exists($default_config['attachment'])) { |
|
| 235 | 235 | $this->default_message_mask = $default_config['attachment']; |
| 236 | - }else{ |
|
| 236 | + }else { |
|
| 237 | 237 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | - }else{ |
|
| 241 | - if(class_exists($default_config['message'])) { |
|
| 240 | + }else { |
|
| 241 | + if (class_exists($default_config['message'])) { |
|
| 242 | 242 | $this->default_message_mask = $default_config['message']; |
| 243 | - }else{ |
|
| 243 | + }else { |
|
| 244 | 244 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - if(class_exists($default_config['attachment'])) { |
|
| 247 | + if (class_exists($default_config['attachment'])) { |
|
| 248 | 248 | $this->default_message_mask = $default_config['attachment']; |
| 249 | - }else{ |
|
| 249 | + }else { |
|
| 250 | 250 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | $timeout = $this->connection !== false ? $this->connection->getConnectionTimeout() : null; |
| 311 | 311 | $this->connection = new ImapProtocol($this->validate_cert); |
| 312 | 312 | $this->connection->setConnectionTimeout($timeout); |
| 313 | - }else{ |
|
| 313 | + }else { |
|
| 314 | 314 | if (extension_loaded('imap') === false) { |
| 315 | 315 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
| 316 | 316 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
| 388 | 388 | $items = $this->connection->folders('', $pattern); |
| 389 | 389 | |
| 390 | - if(is_array($items)){ |
|
| 390 | + if (is_array($items)) { |
|
| 391 | 391 | foreach ($items as $folder_name => $item) { |
| 392 | 392 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
| 393 | 393 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | return $folders; |
| 405 | - }else{ |
|
| 405 | + }else { |
|
| 406 | 406 | throw new FolderFetchingException("failed to fetch any folders"); |
| 407 | 407 | } |
| 408 | 408 | } |
@@ -436,10 +436,10 @@ discard block |
||
| 436 | 436 | public function createFolder($folder, $expunge = true) { |
| 437 | 437 | $this->checkConnection(); |
| 438 | 438 | $status = $this->connection->createFolder($folder); |
| 439 | - if($expunge) $this->expunge(); |
|
| 439 | + if ($expunge) $this->expunge(); |
|
| 440 | 440 | |
| 441 | 441 | $folder = $this->getFolder($folder); |
| 442 | - if($status && $folder) { |
|
| 442 | + if ($status && $folder) { |
|
| 443 | 443 | $event = $this->getEvent("folder", "new"); |
| 444 | 444 | $event::dispatch($folder); |
| 445 | 445 | } |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | * |
| 465 | 465 | * @return Folder |
| 466 | 466 | */ |
| 467 | - public function getFolderPath(){ |
|
| 467 | + public function getFolderPath() { |
|
| 468 | 468 | return $this->active_folder; |
| 469 | 469 | } |
| 470 | 470 | |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | * |
| 519 | 519 | * @return int |
| 520 | 520 | */ |
| 521 | - public function getTimeout($type){ |
|
| 521 | + public function getTimeout($type) { |
|
| 522 | 522 | return $this->connection->getConnectionTimeout(); |
| 523 | 523 | } |
| 524 | 524 | |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | * |
| 528 | 528 | * @return string |
| 529 | 529 | */ |
| 530 | - public function getDefaultMessageMask(){ |
|
| 530 | + public function getDefaultMessageMask() { |
|
| 531 | 531 | return $this->default_message_mask; |
| 532 | 532 | } |
| 533 | 533 | |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | * |
| 538 | 538 | * @return array |
| 539 | 539 | */ |
| 540 | - public function getDefaultEvents($section){ |
|
| 540 | + public function getDefaultEvents($section) { |
|
| 541 | 541 | return $this->events[$section]; |
| 542 | 542 | } |
| 543 | 543 | |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | * @throws MaskNotFoundException |
| 550 | 550 | */ |
| 551 | 551 | public function setDefaultMessageMask($mask) { |
| 552 | - if(class_exists($mask)) { |
|
| 552 | + if (class_exists($mask)) { |
|
| 553 | 553 | $this->default_message_mask = $mask; |
| 554 | 554 | |
| 555 | 555 | return $this; |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | * |
| 564 | 564 | * @return string |
| 565 | 565 | */ |
| 566 | - public function getDefaultAttachmentMask(){ |
|
| 566 | + public function getDefaultAttachmentMask() { |
|
| 567 | 567 | return $this->default_attachment_mask; |
| 568 | 568 | } |
| 569 | 569 | |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | * @throws MaskNotFoundException |
| 576 | 576 | */ |
| 577 | 577 | public function setDefaultAttachmentMask($mask) { |
| 578 | - if(class_exists($mask)) { |
|
| 578 | + if (class_exists($mask)) { |
|
| 579 | 579 | $this->default_attachment_mask = $mask; |
| 580 | 580 | |
| 581 | 581 | return $this; |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return null |
| 32 | 32 | */ |
| 33 | - public function getHtmlBody(){ |
|
| 33 | + public function getHtmlBody() { |
|
| 34 | 34 | $bodies = $this->parent->getBodies(); |
| 35 | 35 | if (!isset($bodies['html'])) { |
| 36 | 36 | return null; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if(is_object($bodies['html']) && property_exists($bodies['html'], 'content')) { |
|
| 39 | + if (is_object($bodies['html']) && property_exists($bodies['html'], 'content')) { |
|
| 40 | 40 | return $bodies['html']->content; |
| 41 | 41 | } |
| 42 | 42 | return $bodies['html']; |
@@ -50,15 +50,15 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function getCustomHTMLBody($callback = false) { |
| 52 | 52 | $body = $this->getHtmlBody(); |
| 53 | - if($body === null) return null; |
|
| 53 | + if ($body === null) return null; |
|
| 54 | 54 | |
| 55 | 55 | if ($callback !== false) { |
| 56 | 56 | $aAttachment = $this->parent->getAttachments(); |
| 57 | 57 | $aAttachment->each(function($oAttachment) use(&$body, $callback) { |
| 58 | 58 | /** @var Attachment $oAttachment */ |
| 59 | - if(is_callable($callback)) { |
|
| 59 | + if (is_callable($callback)) { |
|
| 60 | 60 | $body = $callback($body, $oAttachment); |
| 61 | - }elseif(is_string($callback)) { |
|
| 61 | + }elseif (is_string($callback)) { |
|
| 62 | 62 | call_user_func($callback, [$body, $oAttachment]); |
| 63 | 63 | } |
| 64 | 64 | }); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @return string|null |
| 75 | 75 | */ |
| 76 | 76 | public function getHTMLBodyWithEmbeddedBase64Images() { |
| 77 | - return $this->getCustomHTMLBody(function($body, $oAttachment){ |
|
| 77 | + return $this->getCustomHTMLBody(function($body, $oAttachment) { |
|
| 78 | 78 | /** @var \Webklex\PHPIMAP\Attachment $oAttachment */ |
| 79 | 79 | if ($oAttachment->id) { |
| 80 | 80 | $body = str_replace('cid:'.$oAttachment->id, 'data:'.$oAttachment->getContentType().';base64, '.base64_encode($oAttachment->getContent()), $body); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | public function __construct($msgn, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false) { |
| 195 | 195 | |
| 196 | 196 | $default_mask = $client->getDefaultMessageMask(); |
| 197 | - if($default_mask != null) { |
|
| 197 | + if ($default_mask != null) { |
|
| 198 | 198 | $this->mask = $default_mask; |
| 199 | 199 | } |
| 200 | 200 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -239,13 +239,13 @@ 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 | return $this->get($name); |
| 245 | 245 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
| 246 | 246 | $name = Str::snake(substr($method, 3)); |
| 247 | 247 | |
| 248 | - if(in_array($name, array_keys($this->attributes))) { |
|
| 248 | + if (in_array($name, array_keys($this->attributes))) { |
|
| 249 | 249 | $this->attributes[$name] = array_pop($arguments); |
| 250 | 250 | |
| 251 | 251 | return $this->attributes[$name]; |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * @return mixed|null |
| 287 | 287 | */ |
| 288 | 288 | public function get($name) { |
| 289 | - if(isset($this->attributes[$name])) { |
|
| 289 | + if (isset($this->attributes[$name])) { |
|
| 290 | 290 | return $this->attributes[$name]; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | $flags = $this->client->getConnection()->flags([$this->msgn]); |
| 369 | 369 | |
| 370 | 370 | if (isset($flags[$this->msgn])) { |
| 371 | - foreach($flags[$this->msgn] as $flag) { |
|
| 372 | - if (strpos($flag, "\\") === 0){ |
|
| 371 | + foreach ($flags[$this->msgn] as $flag) { |
|
| 372 | + if (strpos($flag, "\\") === 0) { |
|
| 373 | 373 | $flag = substr($flag, 1); |
| 374 | 374 | } |
| 375 | 375 | $flag_key = strtolower($flag); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | private function fetchPart(Part $part) { |
| 427 | 427 | |
| 428 | - if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])) ) ) { |
|
| 428 | + if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])))) { |
|
| 429 | 429 | |
| 430 | 430 | if (strtolower($part->subtype) == "plain" || strtolower($part->subtype) == "csv") { |
| 431 | 431 | $encoding = $this->getEncoding($part); |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } elseif ($part->ifdisposition == 1 && strtolower($part->disposition) == 'attachment') { |
| 464 | 464 | $this->fetchAttachment($part); |
| 465 | 465 | } |
| 466 | - } else { |
|
| 466 | + }else { |
|
| 467 | 467 | $this->fetchAttachment($part); |
| 468 | 468 | } |
| 469 | 469 | } |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | if ($oAttachment->getName() !== null) { |
| 480 | 480 | if ($oAttachment->getId() !== null) { |
| 481 | 481 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
| 482 | - } else { |
|
| 482 | + }else { |
|
| 483 | 483 | $this->attachments->push($oAttachment); |
| 484 | 484 | } |
| 485 | 485 | } |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
| 598 | 598 | return @iconv($from, $to.'//IGNORE', $str); |
| 599 | - } else { |
|
| 599 | + }else { |
|
| 600 | 600 | if (!$from) { |
| 601 | 601 | return mb_convert_encoding($str, $to); |
| 602 | 602 | } |
@@ -617,9 +617,9 @@ discard block |
||
| 617 | 617 | return EncodingAliases::get($parameter->value); |
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | - }elseif (property_exists($structure, 'charset')){ |
|
| 620 | + }elseif (property_exists($structure, 'charset')) { |
|
| 621 | 621 | return EncodingAliases::get($structure->charset); |
| 622 | - }elseif (is_string($structure) === true){ |
|
| 622 | + }elseif (is_string($structure) === true) { |
|
| 623 | 623 | return mb_detect_encoding($structure); |
| 624 | 624 | } |
| 625 | 625 | |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | * @throws Exceptions\ConnectionFailedException |
| 634 | 634 | * @throws Exceptions\FolderFetchingException |
| 635 | 635 | */ |
| 636 | - public function getFolder(){ |
|
| 636 | + public function getFolder() { |
|
| 637 | 637 | return $this->client->getFolder($this->folder_path); |
| 638 | 638 | } |
| 639 | 639 | |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | */ |
| 711 | 711 | public function delete($expunge = true) { |
| 712 | 712 | $status = $this->setFlag("Deleted"); |
| 713 | - if($expunge) $this->client->expunge(); |
|
| 713 | + if ($expunge) $this->client->expunge(); |
|
| 714 | 714 | |
| 715 | 715 | $event = $this->getEvent("message", "deleted"); |
| 716 | 716 | $event::dispatch($this); |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | */ |
| 730 | 730 | public function restore($expunge = true) { |
| 731 | 731 | $status = $this->unsetFlag("Deleted"); |
| 732 | - if($expunge) $this->client->expunge(); |
|
| 732 | + if ($expunge) $this->client->expunge(); |
|
| 733 | 733 | |
| 734 | 734 | $event = $this->getEvent("message", "restored"); |
| 735 | 735 | $event::dispatch($this); |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | * |
| 883 | 883 | * @return object|null |
| 884 | 884 | */ |
| 885 | - public function getStructure(){ |
|
| 885 | + public function getStructure() { |
|
| 886 | 886 | return $this->structure; |
| 887 | 887 | } |
| 888 | 888 | |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | * |
| 909 | 909 | * @return array |
| 910 | 910 | */ |
| 911 | - public function getAttributes(){ |
|
| 911 | + public function getAttributes() { |
|
| 912 | 912 | return array_merge($this->attributes, $this->header->getAttributes()); |
| 913 | 913 | } |
| 914 | 914 | |
@@ -918,8 +918,8 @@ discard block |
||
| 918 | 918 | * |
| 919 | 919 | * @return $this |
| 920 | 920 | */ |
| 921 | - public function setMask($mask){ |
|
| 922 | - if(class_exists($mask)){ |
|
| 921 | + public function setMask($mask) { |
|
| 922 | + if (class_exists($mask)) { |
|
| 923 | 923 | $this->mask = $mask; |
| 924 | 924 | } |
| 925 | 925 | |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | * |
| 932 | 932 | * @return string |
| 933 | 933 | */ |
| 934 | - public function getMask(){ |
|
| 934 | + public function getMask() { |
|
| 935 | 935 | return $this->mask; |
| 936 | 936 | } |
| 937 | 937 | |
@@ -942,9 +942,9 @@ discard block |
||
| 942 | 942 | * @return mixed |
| 943 | 943 | * @throws MaskNotFoundException |
| 944 | 944 | */ |
| 945 | - public function mask($mask = null){ |
|
| 945 | + public function mask($mask = null) { |
|
| 946 | 946 | $mask = $mask !== null ? $mask : $this->mask; |
| 947 | - if(class_exists($mask)){ |
|
| 947 | + if (class_exists($mask)) { |
|
| 948 | 948 | return new $mask($this); |
| 949 | 949 | } |
| 950 | 950 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $this->part_number = $part->part_number; |
| 105 | 105 | |
| 106 | 106 | $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask(); |
| 107 | - if($default_mask != null) { |
|
| 107 | + if ($default_mask != null) { |
|
| 108 | 108 | $this->mask = $default_mask; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | * @throws MethodNotFoundException |
| 122 | 122 | */ |
| 123 | 123 | public function __call($method, $arguments) { |
| 124 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 124 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 125 | 125 | $name = Str::snake(substr($method, 3)); |
| 126 | 126 | |
| 127 | - if(isset($this->attributes[$name])) { |
|
| 127 | + if (isset($this->attributes[$name])) { |
|
| 128 | 128 | return $this->attributes[$name]; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @return mixed|null |
| 161 | 161 | */ |
| 162 | 162 | public function __get($name) { |
| 163 | - if(isset($this->attributes[$name])) { |
|
| 163 | + if (isset($this->attributes[$name])) { |
|
| 164 | 164 | return $this->attributes[$name]; |
| 165 | 165 | } |
| 166 | 166 | |
@@ -223,14 +223,14 @@ discard block |
||
| 223 | 223 | $this->setName($name); |
| 224 | 224 | }elseif (($filename = $this->part->filename) !== null) { |
| 225 | 225 | $this->setName($filename); |
| 226 | - } else { |
|
| 226 | + }else { |
|
| 227 | 227 | $this->setName("undefined"); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) { |
| 231 | 231 | if ($this->part->ifdescription) { |
| 232 | 232 | $this->setName($this->part->description); |
| 233 | - } else { |
|
| 233 | + }else { |
|
| 234 | 234 | $this->setName($this->part->subtype); |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | public function setName($name) { |
| 257 | 257 | $decoder = $this->config['decoder']['attachment']; |
| 258 | 258 | if ($name !== null) { |
| 259 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 259 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 260 | 260 | $this->name = \imap_utf8($name); |
| 261 | - }else{ |
|
| 261 | + }else { |
|
| 262 | 262 | $this->name = mb_decode_mimeheader($name); |
| 263 | 263 | } |
| 264 | 264 | } |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return string|null |
| 271 | 271 | */ |
| 272 | - public function getMimeType(){ |
|
| 272 | + public function getMimeType() { |
|
| 273 | 273 | return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE); |
| 274 | 274 | } |
| 275 | 275 | |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @return string|null |
| 280 | 280 | */ |
| 281 | - public function getExtension(){ |
|
| 281 | + public function getExtension() { |
|
| 282 | 282 | $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser"; |
| 283 | - if (class_exists($deprecated_guesser) !== false){ |
|
| 283 | + if (class_exists($deprecated_guesser) !== false) { |
|
| 284 | 284 | return $deprecated_guesser::getInstance()->guess($this->getMimeType()); |
| 285 | 285 | } |
| 286 | 286 | $guesser = "\Symfony\Component\Mime\MimeTypes"; |
@@ -293,14 +293,14 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @return array |
| 295 | 295 | */ |
| 296 | - public function getAttributes(){ |
|
| 296 | + public function getAttributes() { |
|
| 297 | 297 | return $this->attributes; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
| 301 | 301 | * @return Message |
| 302 | 302 | */ |
| 303 | - public function getMessage(){ |
|
| 303 | + public function getMessage() { |
|
| 304 | 304 | return $this->oMessage; |
| 305 | 305 | } |
| 306 | 306 | |
@@ -310,8 +310,8 @@ discard block |
||
| 310 | 310 | * |
| 311 | 311 | * @return $this |
| 312 | 312 | */ |
| 313 | - public function setMask($mask){ |
|
| 314 | - if(class_exists($mask)){ |
|
| 313 | + public function setMask($mask) { |
|
| 314 | + if (class_exists($mask)) { |
|
| 315 | 315 | $this->mask = $mask; |
| 316 | 316 | } |
| 317 | 317 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * |
| 324 | 324 | * @return string |
| 325 | 325 | */ |
| 326 | - public function getMask(){ |
|
| 326 | + public function getMask() { |
|
| 327 | 327 | return $this->mask; |
| 328 | 328 | } |
| 329 | 329 | |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | * @return mixed |
| 335 | 335 | * @throws MaskNotFoundException |
| 336 | 336 | */ |
| 337 | - public function mask($mask = null){ |
|
| 337 | + public function mask($mask = null) { |
|
| 338 | 338 | $mask = $mask !== null ? $mask : $this->mask; |
| 339 | - if(class_exists($mask)){ |
|
| 339 | + if (class_exists($mask)) { |
|
| 340 | 340 | return new $mask($this); |
| 341 | 341 | } |
| 342 | 342 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | public function __construct(Client $client, $charset = 'UTF-8') { |
| 74 | 74 | $this->setClient($client); |
| 75 | 75 | |
| 76 | - if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 76 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 77 | 77 | |
| 78 | 78 | $this->date_format = ClientManager::get('date_format', 'd M y'); |
| 79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * Instance boot method for additional functionality |
| 87 | 87 | */ |
| 88 | - protected function boot(){} |
|
| 88 | + protected function boot() {} |
|
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Parse a given value |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @return string |
| 95 | 95 | */ |
| 96 | - protected function parse_value($value){ |
|
| 97 | - switch(true){ |
|
| 96 | + protected function parse_value($value) { |
|
| 97 | + switch (true) { |
|
| 98 | 98 | case $value instanceof \Carbon\Carbon: |
| 99 | 99 | $value = $value->format($this->date_format); |
| 100 | 100 | break; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @throws MessageSearchValidationException |
| 112 | 112 | */ |
| 113 | 113 | protected function parse_date($date) { |
| 114 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 114 | + if ($date instanceof \Carbon\Carbon) return $date; |
|
| 115 | 115 | |
| 116 | 116 | try { |
| 117 | 117 | $date = Carbon::parse($date); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @return Collection |
| 151 | 151 | * @throws GetMessagesFailedException |
| 152 | 152 | */ |
| 153 | - protected function search(){ |
|
| 153 | + protected function search() { |
|
| 154 | 154 | $this->generate_query(); |
| 155 | 155 | |
| 156 | 156 | try { |
@@ -195,15 +195,15 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | $options = ClientManager::get('options'); |
| 197 | 197 | |
| 198 | - if(strtolower($options['fetch_order']) === 'desc'){ |
|
| 198 | + if (strtolower($options['fetch_order']) === 'desc') { |
|
| 199 | 199 | $available_messages = $available_messages->reverse(); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - $query =& $this; |
|
| 202 | + $query = & $this; |
|
| 203 | 203 | |
| 204 | 204 | $available_messages->forPage($this->page, $this->limit)->each(function($msgno, $msglist) use(&$messages, $options, $query) { |
| 205 | 205 | $message = $query->getMessage($msgno, $msglist); |
| 206 | - switch ($options['message_key']){ |
|
| 206 | + switch ($options['message_key']) { |
|
| 207 | 207 | case 'number': |
| 208 | 208 | $message_key = $message->getMessageNo(); |
| 209 | 209 | break; |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | return $messages; |
| 223 | 223 | } catch (\Exception $e) { |
| 224 | - throw new GetMessagesFailedException($e->getMessage(),0, $e); |
|
| 224 | + throw new GetMessagesFailedException($e->getMessage(), 0, $e); |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * @throws MessageHeaderFetchingException |
| 239 | 239 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
| 240 | 240 | */ |
| 241 | - public function getMessage($msgno, $msglist = null){ |
|
| 241 | + public function getMessage($msgno, $msglist = null) { |
|
| 242 | 242 | return new Message($msgno, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags()); |
| 243 | 243 | } |
| 244 | 244 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @return LengthAwarePaginator |
| 252 | 252 | * @throws GetMessagesFailedException |
| 253 | 253 | */ |
| 254 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
| 254 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
| 255 | 255 | if ( |
| 256 | 256 | $page === null |
| 257 | 257 | && isset($_GET[$page_name]) |
@@ -277,10 +277,10 @@ discard block |
||
| 277 | 277 | $this->query->each(function($statement) use(&$query) { |
| 278 | 278 | if (count($statement) == 1) { |
| 279 | 279 | $query .= $statement[0]; |
| 280 | - } else { |
|
| 281 | - if($statement[1] === null){ |
|
| 280 | + }else { |
|
| 281 | + if ($statement[1] === null) { |
|
| 282 | 282 | $query .= $statement[0]; |
| 283 | - }else{ |
|
| 283 | + }else { |
|
| 284 | 284 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 285 | 285 | } |
| 286 | 286 | } |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * @return $this |
| 311 | 311 | */ |
| 312 | 312 | public function limit($limit, $page = 1) { |
| 313 | - if($page >= 1) $this->page = $page; |
|
| 313 | + if ($page >= 1) $this->page = $page; |
|
| 314 | 314 | $this->limit = $limit; |
| 315 | 315 | |
| 316 | 316 | return $this; |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | * @throws MethodNotFoundException |
| 74 | 74 | */ |
| 75 | 75 | public function __call($method, $arguments) { |
| 76 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 76 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 77 | 77 | $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3)); |
| 78 | 78 | |
| 79 | - if(in_array($name, array_keys($this->attributes))) { |
|
| 79 | + if (in_array($name, array_keys($this->attributes))) { |
|
| 80 | 80 | return $this->attributes[$name]; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @return mixed|null |
| 103 | 103 | */ |
| 104 | 104 | public function get($name) { |
| 105 | - if(isset($this->attributes[$name])) { |
|
| 105 | + if (isset($this->attributes[$name])) { |
|
| 106 | 106 | return $this->attributes[$name]; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | public function find($pattern) { |
| 119 | 119 | if (preg_match_all($pattern, $this->raw, $matches)) { |
| 120 | 120 | if (isset($matches[1])) { |
| 121 | - if(count($matches[1]) > 0) { |
|
| 121 | + if (count($matches[1]) > 0) { |
|
| 122 | 122 | return $matches[1][0]; |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @throws InvalidMessageDateException |
| 133 | 133 | */ |
| 134 | - protected function parse(){ |
|
| 134 | + protected function parse() { |
|
| 135 | 135 | $header = $this->rfc822_parse_headers($this->raw); |
| 136 | 136 | |
| 137 | 137 | $this->extractAddresses($header); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $this->parseDate($header); |
| 150 | 150 | foreach ($header as $key => $value) { |
| 151 | 151 | $key = trim(rtrim(strtolower($key))); |
| 152 | - if(!isset($this->attributes[$key])){ |
|
| 152 | + if (!isset($this->attributes[$key])) { |
|
| 153 | 153 | $this->attributes[$key] = $value; |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @return object |
| 167 | 167 | */ |
| 168 | - public function rfc822_parse_headers($raw_headers){ |
|
| 168 | + public function rfc822_parse_headers($raw_headers) { |
|
| 169 | 169 | $headers = []; |
| 170 | 170 | $imap_headers = []; |
| 171 | 171 | if (extension_loaded('imap')) { |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $lines = explode("\r\n", $raw_headers); |
| 176 | 176 | $prev_header = null; |
| 177 | - foreach($lines as $line) { |
|
| 177 | + foreach ($lines as $line) { |
|
| 178 | 178 | if (substr($line, 0, 1) === "\n") { |
| 179 | 179 | $line = substr($line, 1); |
| 180 | 180 | } |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | if (is_array($headers[$prev_header])) { |
| 196 | 196 | $headers[$prev_header][] = $line; |
| 197 | - }else{ |
|
| 197 | + }else { |
|
| 198 | 198 | $headers[$prev_header] .= $line; |
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | - }else{ |
|
| 201 | + }else { |
|
| 202 | 202 | if (($pos = strpos($line, ":")) > 0) { |
| 203 | 203 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
| 204 | 204 | $value = trim(rtrim(strtolower(substr($line, $pos + 1)))); |
@@ -208,10 +208,10 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - foreach($headers as $key => $values) { |
|
| 211 | + foreach ($headers as $key => $values) { |
|
| 212 | 212 | if (isset($imap_headers[$key])) continue; |
| 213 | 213 | $value = null; |
| 214 | - switch($key){ |
|
| 214 | + switch ($key) { |
|
| 215 | 215 | case 'from': |
| 216 | 216 | case 'to': |
| 217 | 217 | case 'cc': |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | break; |
| 227 | 227 | default: |
| 228 | 228 | if (is_array($values)) { |
| 229 | - foreach($values as $k => $v) { |
|
| 229 | + foreach ($values as $k => $v) { |
|
| 230 | 230 | if ($v == "") { |
| 231 | 231 | unset($values[$k]); |
| 232 | 232 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $value = implode(" ", $values); |
| 239 | 239 | } elseif ($available_values > 2) { |
| 240 | 240 | $value = array_values($values); |
| 241 | - } else { |
|
| 241 | + }else { |
|
| 242 | 242 | $value = ""; |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -258,12 +258,12 @@ discard block |
||
| 258 | 258 | * @return array The decoded elements are returned in an array of objects, where each |
| 259 | 259 | * object has two properties, charset and text. |
| 260 | 260 | */ |
| 261 | - public function mime_header_decode($text){ |
|
| 261 | + public function mime_header_decode($text) { |
|
| 262 | 262 | if (extension_loaded('imap')) { |
| 263 | 263 | return \imap_mime_header_decode($text); |
| 264 | 264 | } |
| 265 | 265 | $charset = $this->getEncoding($text); |
| 266 | - return [(object)[ |
|
| 266 | + return [(object) [ |
|
| 267 | 267 | "charset" => $charset, |
| 268 | 268 | "text" => $this->convertEncoding($text, $charset) |
| 269 | 269 | ]]; |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | try { |
| 318 | 318 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
| 319 | 319 | return iconv($from, $to, $str); |
| 320 | - } else { |
|
| 320 | + }else { |
|
| 321 | 321 | if (!$from) { |
| 322 | 322 | return mb_convert_encoding($str, $to); |
| 323 | 323 | } |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | if (strstr($from, '-')) { |
| 328 | 328 | $from = str_replace('-', '', $from); |
| 329 | 329 | return $this->convertEncoding($str, $from, $to); |
| 330 | - } else { |
|
| 330 | + }else { |
|
| 331 | 331 | return $str; |
| 332 | 332 | } |
| 333 | 333 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | } |
| 349 | 349 | }elseif (property_exists($structure, 'charset')) { |
| 350 | 350 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
| 351 | - }elseif (is_string($structure) === true){ |
|
| 351 | + }elseif (is_string($structure) === true) { |
|
| 352 | 352 | return mb_detect_encoding($structure); |
| 353 | 353 | } |
| 354 | 354 | |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | $decoder = $this->config['decoder']['message']; |
| 367 | 367 | |
| 368 | 368 | if ($value !== null) { |
| 369 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 369 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 370 | 370 | $value = \imap_utf8($value); |
| 371 | 371 | if (strpos(strtolower($value), '=?utf-8?') === 0) { |
| 372 | 372 | $value = mb_decode_mimeheader($value); |
@@ -374,14 +374,14 @@ discard block |
||
| 374 | 374 | if ($this->notDecoded($original_value, $value)) { |
| 375 | 375 | $decoded_value = $this->mime_header_decode($value); |
| 376 | 376 | if (count($decoded_value) > 0) { |
| 377 | - if(property_exists($decoded_value[0], "text")) { |
|
| 377 | + if (property_exists($decoded_value[0], "text")) { |
|
| 378 | 378 | $value = $decoded_value[0]->text; |
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | - }elseif($decoder === 'iconv') { |
|
| 382 | + }elseif ($decoder === 'iconv') { |
|
| 383 | 383 | $value = iconv_mime_decode($value); |
| 384 | - }else{ |
|
| 384 | + }else { |
|
| 385 | 385 | $value = mb_decode_mimeheader($value); |
| 386 | 386 | } |
| 387 | 387 | |
@@ -401,8 +401,8 @@ discard block |
||
| 401 | 401 | * Try to extract the priority from a given raw header string |
| 402 | 402 | */ |
| 403 | 403 | private function findPriority() { |
| 404 | - if(($priority = $this->get("x-priority")) === null) return; |
|
| 405 | - switch($priority){ |
|
| 404 | + if (($priority = $this->get("x-priority")) === null) return; |
|
| 405 | + switch ($priority) { |
|
| 406 | 406 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 407 | 407 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 408 | 408 | break; |
@@ -434,12 +434,12 @@ discard block |
||
| 434 | 434 | */ |
| 435 | 435 | private function decodeAddresses($values) { |
| 436 | 436 | $addresses = []; |
| 437 | - foreach($values as $address) { |
|
| 437 | + foreach ($values as $address) { |
|
| 438 | 438 | if (preg_match( |
| 439 | 439 | '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/', |
| 440 | 440 | $address, |
| 441 | 441 | $matches |
| 442 | - )){ |
|
| 442 | + )) { |
|
| 443 | 443 | $name = trim(rtrim($matches["name"])); |
| 444 | 444 | $email = trim(rtrim($matches["email"])); |
| 445 | 445 | list($mailbox, $host) = array_pad(explode("@", $email), 2, null); |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @param object $header |
| 459 | 459 | */ |
| 460 | 460 | private function extractAddresses($header) { |
| 461 | - foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender', 'in_reply_to'] as $key){ |
|
| 461 | + foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender', 'in_reply_to'] as $key) { |
|
| 462 | 462 | if (property_exists($header, $key)) { |
| 463 | 463 | $this->attributes[$key] = $this->parseAddresses($header->$key); |
| 464 | 464 | } |
@@ -485,10 +485,10 @@ discard block |
||
| 485 | 485 | } |
| 486 | 486 | if (!property_exists($address, 'personal')) { |
| 487 | 487 | $address->personal = false; |
| 488 | - } else { |
|
| 488 | + }else { |
|
| 489 | 489 | $personalParts = $this->mime_header_decode($address->personal); |
| 490 | 490 | |
| 491 | - if(is_array($personalParts)) { |
|
| 491 | + if (is_array($personalParts)) { |
|
| 492 | 492 | $address->personal = ''; |
| 493 | 493 | foreach ($personalParts as $p) { |
| 494 | 494 | $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p)); |
@@ -508,18 +508,18 @@ discard block |
||
| 508 | 508 | /** |
| 509 | 509 | * Search and extract potential header extensions |
| 510 | 510 | */ |
| 511 | - private function extractHeaderExtensions(){ |
|
| 511 | + private function extractHeaderExtensions() { |
|
| 512 | 512 | foreach ($this->attributes as $key => $value) { |
| 513 | 513 | // Only parse strings and don't parse any attributes like the user-agent |
| 514 | 514 | if (is_string($value) === true && in_array($key, ["user-agent"]) === false) { |
| 515 | - if (($pos = strpos($value, ";")) !== false){ |
|
| 515 | + if (($pos = strpos($value, ";")) !== false) { |
|
| 516 | 516 | $original = substr($value, 0, $pos); |
| 517 | 517 | $this->attributes[$key] = trim(rtrim($original)); |
| 518 | 518 | |
| 519 | 519 | // Get all potential extensions |
| 520 | 520 | $extensions = explode(";", substr($value, $pos + 1)); |
| 521 | - foreach($extensions as $extension) { |
|
| 522 | - if (($pos = strpos($extension, "=")) !== false){ |
|
| 521 | + foreach ($extensions as $extension) { |
|
| 522 | + if (($pos = strpos($extension, "=")) !== false) { |
|
| 523 | 523 | $key = substr($extension, 0, $pos); |
| 524 | 524 | $value = substr($extension, $pos + 1); |
| 525 | 525 | $value = str_replace('"', "", $value); |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | $parsed_date = null; |
| 557 | 557 | $date = $header->date; |
| 558 | 558 | |
| 559 | - if(preg_match('/\+0580/', $date)) { |
|
| 559 | + if (preg_match('/\+0580/', $date)) { |
|
| 560 | 560 | $date = str_replace('+0580', '+0530', $date); |
| 561 | 561 | } |
| 562 | 562 | |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | $date = trim(array_pop($array)); |
| 580 | 580 | break; |
| 581 | 581 | } |
| 582 | - try{ |
|
| 582 | + try { |
|
| 583 | 583 | $parsed_date = Carbon::parse($date); |
| 584 | 584 | } catch (\Exception $_e) { |
| 585 | 585 | throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e); |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @throws InvalidMessageDateException |
| 161 | 161 | */ |
| 162 | - protected function parse(){ |
|
| 162 | + protected function parse() { |
|
| 163 | 163 | if ($this->header === null) { |
| 164 | 164 | $body = $this->findHeaders(); |
| 165 | - }else{ |
|
| 165 | + }else { |
|
| 166 | 166 | $body = $this->raw; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -175,18 +175,18 @@ discard block |
||
| 175 | 175 | $this->name = $this->header->get("name"); |
| 176 | 176 | $this->filename = $this->header->get("filename"); |
| 177 | 177 | |
| 178 | - if(!empty($this->header->get("id"))) { |
|
| 178 | + if (!empty($this->header->get("id"))) { |
|
| 179 | 179 | $this->id = $this->header->get("id"); |
| 180 | - } else if(!empty($this->header->get("x-attachment-id"))){ |
|
| 180 | + }else if (!empty($this->header->get("x-attachment-id"))) { |
|
| 181 | 181 | $this->id = $this->header->get("x-attachment-id"); |
| 182 | - } else if(!empty($this->header->get("content-id"))){ |
|
| 182 | + }else if (!empty($this->header->get("content-id"))) { |
|
| 183 | 183 | $this->id = strtr($this->header->get("content-id"), [ |
| 184 | 184 | '<' => '', |
| 185 | 185 | '>' => '' |
| 186 | 186 | ]); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if(!empty($this->header->get("content-type"))){ |
|
| 189 | + if (!empty($this->header->get("content-type"))) { |
|
| 190 | 190 | $rawContentType = $this->header->get("content-type"); |
| 191 | 191 | $contentTypeArray = explode(';', $rawContentType); |
| 192 | 192 | $this->content_type = trim($contentTypeArray[0]); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @return string |
| 204 | 204 | * @throws InvalidMessageDateException |
| 205 | 205 | */ |
| 206 | - private function findHeaders(){ |
|
| 206 | + private function findHeaders() { |
|
| 207 | 207 | $body = $this->raw; |
| 208 | 208 | while (($pos = strpos($body, "\r\n")) > 0) { |
| 209 | 209 | $body = substr($body, $pos + 2); |
@@ -219,9 +219,9 @@ discard block |
||
| 219 | 219 | /** |
| 220 | 220 | * Try to parse the subtype if any is present |
| 221 | 221 | */ |
| 222 | - private function parseSubtype(){ |
|
| 222 | + private function parseSubtype() { |
|
| 223 | 223 | $content_type = $this->header->get("content-type"); |
| 224 | - if (($pos = strpos($content_type, "/")) !== false){ |
|
| 224 | + if (($pos = strpos($content_type, "/")) !== false) { |
|
| 225 | 225 | $this->subtype = substr($content_type, $pos + 1); |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -229,9 +229,9 @@ discard block |
||
| 229 | 229 | /** |
| 230 | 230 | * Try to parse the disposition if any is present |
| 231 | 231 | */ |
| 232 | - private function parseDisposition(){ |
|
| 232 | + private function parseDisposition() { |
|
| 233 | 233 | $content_disposition = $this->header->get("content-disposition"); |
| 234 | - if($content_disposition !== null) { |
|
| 234 | + if ($content_disposition !== null) { |
|
| 235 | 235 | $this->ifdisposition = true; |
| 236 | 236 | $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition; |
| 237 | 237 | } |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | /** |
| 241 | 241 | * Try to parse the description if any is present |
| 242 | 242 | */ |
| 243 | - private function parseDescription(){ |
|
| 243 | + private function parseDescription() { |
|
| 244 | 244 | $content_description = $this->header->get("content-description"); |
| 245 | - if($content_description !== null) { |
|
| 245 | + if ($content_description !== null) { |
|
| 246 | 246 | $this->ifdescription = true; |
| 247 | 247 | $this->description = $content_description; |
| 248 | 248 | } |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | /** |
| 252 | 252 | * Try to parse the encoding if any is present |
| 253 | 253 | */ |
| 254 | - private function parseEncoding(){ |
|
| 254 | + private function parseEncoding() { |
|
| 255 | 255 | $encoding = $this->header->get("content-transfer-encoding"); |
| 256 | - if($encoding !== null) { |
|
| 256 | + if ($encoding !== null) { |
|
| 257 | 257 | switch (strtolower($encoding)) { |
| 258 | 258 | case "quoted-printable": |
| 259 | 259 | $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE; |