@@ -65,7 +65,7 @@ |
||
| 65 | 65 | * |
| 66 | 66 | * @return array |
| 67 | 67 | */ |
| 68 | - public function getEvents(){ |
|
| 68 | + public function getEvents() { |
|
| 69 | 69 | return $this->events; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return null; |
| 121 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 121 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 122 | 122 | $name = Str::snake(substr($method, 3)); |
| 123 | 123 | |
| 124 | 124 | $this->attributes[$name] = array_pop($arguments); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | if (($name = $this->part->name) !== null) { |
| 209 | 209 | $this->setName($name); |
| 210 | 210 | $this->disposition = $this->part->disposition; |
| 211 | - }elseif (($filename = $this->part->filename) !== null) { |
|
| 211 | + } elseif (($filename = $this->part->filename) !== null) { |
|
| 212 | 212 | $this->setName($filename); |
| 213 | 213 | $this->disposition = $this->part->disposition; |
| 214 | 214 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | if ($name !== null) { |
| 245 | 245 | if($decoder === 'utf-8' && extension_loaded('imap')) { |
| 246 | 246 | $this->name = \imap_utf8($name); |
| 247 | - }else{ |
|
| 247 | + } else{ |
|
| 248 | 248 | $this->name = mb_decode_mimeheader($name); |
| 249 | 249 | } |
| 250 | 250 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $this->part = $part; |
| 93 | 93 | |
| 94 | 94 | $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask(); |
| 95 | - if($default_mask != null) { |
|
| 95 | + if ($default_mask != null) { |
|
| 96 | 96 | $this->mask = $default_mask; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | * @throws MethodNotFoundException |
| 110 | 110 | */ |
| 111 | 111 | public function __call($method, $arguments) { |
| 112 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 112 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 113 | 113 | $name = Str::snake(substr($method, 3)); |
| 114 | 114 | |
| 115 | - if(isset($this->attributes[$name])) { |
|
| 115 | + if (isset($this->attributes[$name])) { |
|
| 116 | 116 | return $this->attributes[$name]; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @return mixed|null |
| 147 | 147 | */ |
| 148 | 148 | public function __get($name) { |
| 149 | - if(isset($this->attributes[$name])) { |
|
| 149 | + if (isset($this->attributes[$name])) { |
|
| 150 | 150 | return $this->attributes[$name]; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) { |
| 216 | 216 | if ($this->part->ifdescription) { |
| 217 | 217 | $this->setName($this->part->description); |
| 218 | - } else { |
|
| 218 | + }else { |
|
| 219 | 219 | $this->setName($this->part->subtype); |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | public function setName($name) { |
| 242 | 242 | $decoder = $this->config['decoder']['attachment']; |
| 243 | 243 | if ($name !== null) { |
| 244 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 244 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 245 | 245 | $this->name = \imap_utf8($name); |
| 246 | - }else{ |
|
| 246 | + }else { |
|
| 247 | 247 | $this->name = mb_decode_mimeheader($name); |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -252,16 +252,16 @@ discard block |
||
| 252 | 252 | /** |
| 253 | 253 | * @return string|null |
| 254 | 254 | */ |
| 255 | - public function getMimeType(){ |
|
| 255 | + public function getMimeType() { |
|
| 256 | 256 | return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE); |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | 260 | * @return string|null |
| 261 | 261 | */ |
| 262 | - public function getExtension(){ |
|
| 262 | + public function getExtension() { |
|
| 263 | 263 | $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser"; |
| 264 | - if (class_exists($deprecated_guesser) !== false){ |
|
| 264 | + if (class_exists($deprecated_guesser) !== false) { |
|
| 265 | 265 | return $deprecated_guesser::getInstance()->guess($this->getMimeType()); |
| 266 | 266 | } |
| 267 | 267 | $guesser = "\Symfony\Component\Mime\MimeTypes"; |
@@ -272,14 +272,14 @@ discard block |
||
| 272 | 272 | /** |
| 273 | 273 | * @return array |
| 274 | 274 | */ |
| 275 | - public function getAttributes(){ |
|
| 275 | + public function getAttributes() { |
|
| 276 | 276 | return $this->attributes; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | 280 | * @return Message |
| 281 | 281 | */ |
| 282 | - public function getMessage(){ |
|
| 282 | + public function getMessage() { |
|
| 283 | 283 | return $this->oMessage; |
| 284 | 284 | } |
| 285 | 285 | |
@@ -287,8 +287,8 @@ discard block |
||
| 287 | 287 | * @param $mask |
| 288 | 288 | * @return $this |
| 289 | 289 | */ |
| 290 | - public function setMask($mask){ |
|
| 291 | - if(class_exists($mask)){ |
|
| 290 | + public function setMask($mask) { |
|
| 291 | + if (class_exists($mask)) { |
|
| 292 | 292 | $this->mask = $mask; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | /** |
| 299 | 299 | * @return string |
| 300 | 300 | */ |
| 301 | - public function getMask(){ |
|
| 301 | + public function getMask() { |
|
| 302 | 302 | return $this->mask; |
| 303 | 303 | } |
| 304 | 304 | |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | * @return mixed |
| 310 | 310 | * @throws MaskNotFoundException |
| 311 | 311 | */ |
| 312 | - public function mask($mask = null){ |
|
| 312 | + public function mask($mask = null) { |
|
| 313 | 313 | $mask = $mask !== null ? $mask : $this->mask; |
| 314 | - if(class_exists($mask)){ |
|
| 314 | + if (class_exists($mask)) { |
|
| 315 | 315 | return new $mask($this); |
| 316 | 316 | } |
| 317 | 317 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @throws MessageContentFetchingException |
| 70 | 70 | * @throws InvalidMessageDateException |
| 71 | 71 | */ |
| 72 | - protected function parse(){ |
|
| 72 | + protected function parse() { |
|
| 73 | 73 | $this->findContentType(); |
| 74 | 74 | $this->parts = $this->find_parts(); |
| 75 | 75 | } |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * Determine the message content type |
| 79 | 79 | */ |
| 80 | - public function findContentType(){ |
|
| 81 | - if(stripos($this->header->get("content-type"), 'multipart') === 0) { |
|
| 80 | + public function findContentType() { |
|
| 81 | + if (stripos($this->header->get("content-type"), 'multipart') === 0) { |
|
| 82 | 82 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
| 83 | - }else{ |
|
| 83 | + }else { |
|
| 84 | 84 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | /** |
| 89 | 89 | * Determine the message content type |
| 90 | 90 | */ |
| 91 | - public function getBoundary(){ |
|
| 91 | + public function getBoundary() { |
|
| 92 | 92 | return $this->header->find("/boundary\=\"(.*)\"/"); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -97,15 +97,15 @@ discard block |
||
| 97 | 97 | * @throws MessageContentFetchingException |
| 98 | 98 | * @throws InvalidMessageDateException |
| 99 | 99 | */ |
| 100 | - public function find_parts(){ |
|
| 101 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
| 102 | - if (($boundary = $this->getBoundary()) === null) { |
|
| 100 | + public function find_parts() { |
|
| 101 | + if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
| 102 | + if (($boundary = $this->getBoundary()) === null) { |
|
| 103 | 103 | throw new MessageContentFetchingException("no content found", 0); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $raw_parts = explode($boundary, $this->raw); |
| 107 | 107 | $parts = []; |
| 108 | - foreach($raw_parts as $part) { |
|
| 108 | + foreach ($raw_parts as $part) { |
|
| 109 | 109 | $part = trim(rtrim($part)); |
| 110 | 110 | if ($part !== "--") { |
| 111 | 111 | $parts[] = new Part($part); |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | public function findContentType(){ |
| 81 | 81 | if(stripos($this->header->get("content-type"), 'multipart') === 0) { |
| 82 | 82 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
| 83 | - }else{ |
|
| 83 | + } else{ |
|
| 84 | 84 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -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 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * @throws MessageContentFetchingException |
| 238 | 238 | * @throws MessageHeaderFetchingException |
| 239 | 239 | */ |
| 240 | - public function getMessage($msgno, $msglist = null){ |
|
| 240 | + public function getMessage($msgno, $msglist = null) { |
|
| 241 | 241 | return new Message($msgno, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags()); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * @return LengthAwarePaginator |
| 251 | 251 | * @throws GetMessagesFailedException |
| 252 | 252 | */ |
| 253 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
| 253 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
| 254 | 254 | $this->page = $page > $this->page ? $page : $this->page; |
| 255 | 255 | $this->limit = $per_page; |
| 256 | 256 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $messages->each(function($message) use(&$collection){ |
| 262 | 262 | $collection[] = $message; |
| 263 | 263 | }); |
| 264 | - }else{ |
|
| 264 | + }else { |
|
| 265 | 265 | $collection = array_fill(0, $messages->total(), true); |
| 266 | 266 | } |
| 267 | 267 | |
@@ -278,10 +278,10 @@ discard block |
||
| 278 | 278 | $this->query->each(function($statement) use(&$query) { |
| 279 | 279 | if (count($statement) == 1) { |
| 280 | 280 | $query .= $statement[0]; |
| 281 | - } else { |
|
| 282 | - if($statement[1] === null){ |
|
| 281 | + }else { |
|
| 282 | + if ($statement[1] === null) { |
|
| 283 | 283 | $query .= $statement[0]; |
| 284 | - }else{ |
|
| 284 | + }else { |
|
| 285 | 285 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 286 | 286 | } |
| 287 | 287 | } |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @return $this |
| 312 | 312 | */ |
| 313 | 313 | public function limit($limit, $page = 1) { |
| 314 | - if($page >= 1) $this->page = $page; |
|
| 314 | + if ($page >= 1) $this->page = $page; |
|
| 315 | 315 | $this->limit = $limit; |
| 316 | 316 | |
| 317 | 317 | return $this; |
@@ -73,7 +73,9 @@ 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) { |
|
| 77 | + $this->leaveUnread(); |
|
| 78 | + } |
|
| 77 | 79 | |
| 78 | 80 | $this->date_format = ClientManager::get('date_format', 'd M y'); |
| 79 | 81 | |
@@ -111,7 +113,9 @@ discard block |
||
| 111 | 113 | * @throws MessageSearchValidationException |
| 112 | 114 | */ |
| 113 | 115 | protected function parse_date($date) { |
| 114 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 116 | + if($date instanceof \Carbon\Carbon) { |
|
| 117 | + return $date; |
|
| 118 | + } |
|
| 115 | 119 | |
| 116 | 120 | try { |
| 117 | 121 | $date = Carbon::parse($date); |
@@ -261,7 +265,7 @@ discard block |
||
| 261 | 265 | $messages->each(function($message) use(&$collection){ |
| 262 | 266 | $collection[] = $message; |
| 263 | 267 | }); |
| 264 | - }else{ |
|
| 268 | + } else{ |
|
| 265 | 269 | $collection = array_fill(0, $messages->total(), true); |
| 266 | 270 | } |
| 267 | 271 | |
@@ -281,7 +285,7 @@ discard block |
||
| 281 | 285 | } else { |
| 282 | 286 | if($statement[1] === null){ |
| 283 | 287 | $query .= $statement[0]; |
| 284 | - }else{ |
|
| 288 | + } else{ |
|
| 285 | 289 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 286 | 290 | } |
| 287 | 291 | } |
@@ -311,7 +315,9 @@ discard block |
||
| 311 | 315 | * @return $this |
| 312 | 316 | */ |
| 313 | 317 | public function limit($limit, $page = 1) { |
| 314 | - if($page >= 1) $this->page = $page; |
|
| 318 | + if($page >= 1) { |
|
| 319 | + $this->page = $page; |
|
| 320 | + } |
|
| 315 | 321 | $this->limit = $limit; |
| 316 | 322 | |
| 317 | 323 | return $this; |
@@ -76,18 +76,18 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $name = Str::camel($name); |
| 78 | 78 | |
| 79 | - if(strtolower(substr($name, 0, 3)) === 'not') { |
|
| 79 | + if (strtolower(substr($name, 0, 3)) === 'not') { |
|
| 80 | 80 | $that = $that->whereNot(); |
| 81 | 81 | $name = substr($name, 3); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if (strpos(strtolower($name), "where") === false){ |
|
| 84 | + if (strpos(strtolower($name), "where") === false) { |
|
| 85 | 85 | $method = 'where'.ucfirst($name); |
| 86 | - }else{ |
|
| 86 | + }else { |
|
| 87 | 87 | $method = lcfirst($name); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if(method_exists($this, $method) === true){ |
|
| 90 | + if (method_exists($this, $method) === true) { |
|
| 91 | 91 | return call_user_func_array([$that, $method], $arguments); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | if (substr($criteria, 0, 7) === "CUSTOM ") { |
| 107 | 107 | return substr($criteria, 7); |
| 108 | 108 | } |
| 109 | - if(in_array($criteria, $this->available_criteria) === false) { |
|
| 109 | + if (in_array($criteria, $this->available_criteria) === false) { |
|
| 110 | 110 | throw new InvalidWhereQueryCriteriaException(); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -121,20 +121,20 @@ discard block |
||
| 121 | 121 | * @throws InvalidWhereQueryCriteriaException |
| 122 | 122 | */ |
| 123 | 123 | public function where($criteria, $value = null) { |
| 124 | - if(is_array($criteria)){ |
|
| 125 | - foreach($criteria as $key => $value){ |
|
| 126 | - if(is_numeric($key)){ |
|
| 124 | + if (is_array($criteria)) { |
|
| 125 | + foreach ($criteria as $key => $value) { |
|
| 126 | + if (is_numeric($key)) { |
|
| 127 | 127 | return $this->where($value); |
| 128 | 128 | } |
| 129 | 129 | return $this->where($key, $value); |
| 130 | 130 | } |
| 131 | - }else{ |
|
| 131 | + }else { |
|
| 132 | 132 | $criteria = $this->validate_criteria($criteria); |
| 133 | 133 | $value = $this->parse_value($value); |
| 134 | 134 | |
| 135 | - if($value === null || $value === ''){ |
|
| 135 | + if ($value === null || $value === '') { |
|
| 136 | 136 | $this->query->push([$criteria]); |
| 137 | - }else{ |
|
| 137 | + }else { |
|
| 138 | 138 | $this->query->push([$criteria, $value]); |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function orWhere(\Closure $closure = null) { |
| 151 | 151 | $this->query->push(['OR']); |
| 152 | - if($closure !== null) $closure($this); |
|
| 152 | + if ($closure !== null) $closure($this); |
|
| 153 | 153 | |
| 154 | 154 | return $this; |
| 155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function andWhere(\Closure $closure = null) { |
| 163 | 163 | $this->query->push(['AND']); |
| 164 | - if($closure !== null) $closure($this); |
|
| 164 | + if ($closure !== null) $closure($this); |
|
| 165 | 165 | |
| 166 | 166 | return $this; |
| 167 | 167 | } |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * @return WhereQuery |
| 402 | 402 | * @throws InvalidWhereQueryCriteriaException |
| 403 | 403 | */ |
| 404 | - public function whereNoXSpam(){ |
|
| 404 | + public function whereNoXSpam() { |
|
| 405 | 405 | return $this->where("CUSTOM X-Spam-Flag NO"); |
| 406 | 406 | } |
| 407 | 407 | |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | * @return WhereQuery |
| 410 | 410 | * @throws InvalidWhereQueryCriteriaException |
| 411 | 411 | */ |
| 412 | - public function whereIsXSpam(){ |
|
| 412 | + public function whereIsXSpam() { |
|
| 413 | 413 | return $this->where("CUSTOM X-Spam-Flag YES"); |
| 414 | 414 | } |
| 415 | 415 | |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | * @return WhereQuery |
| 420 | 420 | * @throws InvalidWhereQueryCriteriaException |
| 421 | 421 | */ |
| 422 | - public function whereLanguage($country_code){ |
|
| 422 | + public function whereLanguage($country_code) { |
|
| 423 | 423 | return $this->where("Content-Language $country_code"); |
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | \ No newline at end of file |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | if (strpos(strtolower($name), "where") === false){ |
| 85 | 85 | $method = 'where'.ucfirst($name); |
| 86 | - }else{ |
|
| 86 | + } else{ |
|
| 87 | 87 | $method = lcfirst($name); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -128,13 +128,13 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | return $this->where($key, $value); |
| 130 | 130 | } |
| 131 | - }else{ |
|
| 131 | + } else{ |
|
| 132 | 132 | $criteria = $this->validate_criteria($criteria); |
| 133 | 133 | $value = $this->parse_value($value); |
| 134 | 134 | |
| 135 | 135 | if($value === null || $value === ''){ |
| 136 | 136 | $this->query->push([$criteria]); |
| 137 | - }else{ |
|
| 137 | + } else{ |
|
| 138 | 138 | $this->query->push([$criteria, $value]); |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -149,7 +149,9 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function orWhere(\Closure $closure = null) { |
| 151 | 151 | $this->query->push(['OR']); |
| 152 | - if($closure !== null) $closure($this); |
|
| 152 | + if($closure !== null) { |
|
| 153 | + $closure($this); |
|
| 154 | + } |
|
| 153 | 155 | |
| 154 | 156 | return $this; |
| 155 | 157 | } |
@@ -161,7 +163,9 @@ discard block |
||
| 161 | 163 | */ |
| 162 | 164 | public function andWhere(\Closure $closure = null) { |
| 163 | 165 | $this->query->push(['AND']); |
| 164 | - if($closure !== null) $closure($this); |
|
| 166 | + if($closure !== null) { |
|
| 167 | + $closure($this); |
|
| 168 | + } |
|
| 165 | 169 | |
| 166 | 170 | return $this; |
| 167 | 171 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * Parse the raw parts |
| 117 | 117 | * @throws InvalidMessageDateException |
| 118 | 118 | */ |
| 119 | - protected function parse(){ |
|
| 119 | + protected function parse() { |
|
| 120 | 120 | $body = $this->raw; |
| 121 | 121 | |
| 122 | 122 | if ($this->header === null) { |
@@ -144,32 +144,32 @@ discard block |
||
| 144 | 144 | $this->bytes = strlen($this->content); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - private function parseSubtype(){ |
|
| 147 | + private function parseSubtype() { |
|
| 148 | 148 | $content_type = $this->header->get("content-type"); |
| 149 | - if (($pos = strpos($content_type, "/")) !== false){ |
|
| 149 | + if (($pos = strpos($content_type, "/")) !== false) { |
|
| 150 | 150 | $this->subtype = substr($content_type, $pos + 1); |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - private function parseDisposition(){ |
|
| 154 | + private function parseDisposition() { |
|
| 155 | 155 | $content_disposition = $this->header->get("content-disposition"); |
| 156 | - if($content_disposition !== null) { |
|
| 156 | + if ($content_disposition !== null) { |
|
| 157 | 157 | $this->ifdisposition = true; |
| 158 | 158 | $this->disposition = $content_disposition; |
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - private function parseDescription(){ |
|
| 162 | + private function parseDescription() { |
|
| 163 | 163 | $content_description = $this->header->get("content-description"); |
| 164 | - if($content_description !== null) { |
|
| 164 | + if ($content_description !== null) { |
|
| 165 | 165 | $this->ifdescription = true; |
| 166 | 166 | $this->description = $content_description; |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - private function parseEncoding(){ |
|
| 170 | + private function parseEncoding() { |
|
| 171 | 171 | $encoding = $this->header->get("content-transfer-encoding"); |
| 172 | - if($encoding !== null) { |
|
| 172 | + if ($encoding !== null) { |
|
| 173 | 173 | switch (strtolower($encoding)) { |
| 174 | 174 | case "quoted-printable": |
| 175 | 175 | $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE; |
@@ -68,17 +68,17 @@ discard block |
||
| 68 | 68 | public static function get($key, $default = null) { |
| 69 | 69 | $parts = explode('.', $key); |
| 70 | 70 | $value = null; |
| 71 | - foreach($parts as $part) { |
|
| 72 | - if($value === null) { |
|
| 73 | - if(isset(self::$config[$part])) { |
|
| 71 | + foreach ($parts as $part) { |
|
| 72 | + if ($value === null) { |
|
| 73 | + if (isset(self::$config[$part])) { |
|
| 74 | 74 | $value = self::$config[$part]; |
| 75 | - }else{ |
|
| 75 | + }else { |
|
| 76 | 76 | break; |
| 77 | 77 | } |
| 78 | - }else{ |
|
| 79 | - if(isset($value[$part])) { |
|
| 78 | + }else { |
|
| 79 | + if (isset($value[$part])) { |
|
| 80 | 80 | $value = $value[$part]; |
| 81 | - }else{ |
|
| 81 | + }else { |
|
| 82 | 82 | break; |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function setConfig($config) { |
| 173 | 173 | |
| 174 | - if(is_array($config) === false) { |
|
| 174 | + if (is_array($config) === false) { |
|
| 175 | 175 | $config = require $config; |
| 176 | 176 | } |
| 177 | 177 | |
@@ -181,17 +181,17 @@ discard block |
||
| 181 | 181 | $vendor_config = require $path; |
| 182 | 182 | $config = $this->array_merge_recursive_distinct($vendor_config, $config); |
| 183 | 183 | |
| 184 | - if(is_array($config)){ |
|
| 185 | - if(isset($config['default'])){ |
|
| 186 | - if(isset($config['accounts']) && $config['default'] != false){ |
|
| 184 | + if (is_array($config)) { |
|
| 185 | + if (isset($config['default'])) { |
|
| 186 | + if (isset($config['accounts']) && $config['default'] != false) { |
|
| 187 | 187 | |
| 188 | 188 | $default_config = $vendor_config['accounts']['default']; |
| 189 | - if(isset($config['accounts'][$config['default']])){ |
|
| 189 | + if (isset($config['accounts'][$config['default']])) { |
|
| 190 | 190 | $default_config = array_merge($default_config, $config['accounts'][$config['default']]); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if(is_array($config['accounts'])){ |
|
| 194 | - foreach($config['accounts'] as $account_key => $account){ |
|
| 193 | + if (is_array($config['accounts'])) { |
|
| 194 | + foreach ($config['accounts'] as $account_key => $account) { |
|
| 195 | 195 | $config['accounts'][$account_key] = array_merge($default_config, $account); |
| 196 | 196 | } |
| 197 | 197 | } |
@@ -227,24 +227,24 @@ discard block |
||
| 227 | 227 | $arrays = func_get_args(); |
| 228 | 228 | $base = array_shift($arrays); |
| 229 | 229 | |
| 230 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
| 230 | + if (!is_array($base)) $base = empty($base) ? array() : array($base); |
|
| 231 | 231 | |
| 232 | - foreach($arrays as $append) { |
|
| 232 | + foreach ($arrays as $append) { |
|
| 233 | 233 | |
| 234 | - if(!is_array($append)) $append = array($append); |
|
| 234 | + if (!is_array($append)) $append = array($append); |
|
| 235 | 235 | |
| 236 | - foreach($append as $key => $value) { |
|
| 236 | + foreach ($append as $key => $value) { |
|
| 237 | 237 | |
| 238 | - if(!array_key_exists($key, $base) and !is_numeric($key)) { |
|
| 238 | + if (!array_key_exists($key, $base) and !is_numeric($key)) { |
|
| 239 | 239 | $base[$key] = $append[$key]; |
| 240 | 240 | continue; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - if(is_array($value) or is_array($base[$key])) { |
|
| 243 | + if (is_array($value) or is_array($base[$key])) { |
|
| 244 | 244 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]); |
| 245 | - } else if(is_numeric($key)) { |
|
| 246 | - if(!in_array($value, $base)) $base[] = $value; |
|
| 247 | - } else { |
|
| 245 | + }else if (is_numeric($key)) { |
|
| 246 | + if (!in_array($value, $base)) $base[] = $value; |
|
| 247 | + }else { |
|
| 248 | 248 | $base[$key] = $value; |
| 249 | 249 | } |
| 250 | 250 | |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | if($value === null) { |
| 73 | 73 | if(isset(self::$config[$part])) { |
| 74 | 74 | $value = self::$config[$part]; |
| 75 | - }else{ |
|
| 75 | + } else{ |
|
| 76 | 76 | break; |
| 77 | 77 | } |
| 78 | - }else{ |
|
| 78 | + } else{ |
|
| 79 | 79 | if(isset($value[$part])) { |
| 80 | 80 | $value = $value[$part]; |
| 81 | - }else{ |
|
| 81 | + } else{ |
|
| 82 | 82 | break; |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -227,11 +227,15 @@ discard block |
||
| 227 | 227 | $arrays = func_get_args(); |
| 228 | 228 | $base = array_shift($arrays); |
| 229 | 229 | |
| 230 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
| 230 | + if(!is_array($base)) { |
|
| 231 | + $base = empty($base) ? array() : array($base); |
|
| 232 | + } |
|
| 231 | 233 | |
| 232 | 234 | foreach($arrays as $append) { |
| 233 | 235 | |
| 234 | - if(!is_array($append)) $append = array($append); |
|
| 236 | + if(!is_array($append)) { |
|
| 237 | + $append = array($append); |
|
| 238 | + } |
|
| 235 | 239 | |
| 236 | 240 | foreach($append as $key => $value) { |
| 237 | 241 | |
@@ -243,7 +247,9 @@ discard block |
||
| 243 | 247 | if(is_array($value) or is_array($base[$key])) { |
| 244 | 248 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]); |
| 245 | 249 | } else if(is_numeric($key)) { |
| 246 | - if(!in_array($value, $base)) $base[] = $value; |
|
| 250 | + if(!in_array($value, $base)) { |
|
| 251 | + $base[] = $value; |
|
| 252 | + } |
|
| 247 | 253 | } else { |
| 248 | 254 | $base[$key] = $value; |
| 249 | 255 | } |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | * @param array $config |
| 169 | 169 | * @param array $default_config |
| 170 | 170 | */ |
| 171 | - private function setAccountConfig($key, $config, $default_config){ |
|
| 171 | + private function setAccountConfig($key, $config, $default_config) { |
|
| 172 | 172 | $value = $this->default_account_config[$key]; |
| 173 | - if(isset($config[$key])) { |
|
| 173 | + if (isset($config[$key])) { |
|
| 174 | 174 | $value = $config[$key]; |
| 175 | - }elseif(isset($default_config[$key])) { |
|
| 175 | + }elseif (isset($default_config[$key])) { |
|
| 176 | 176 | $value = $default_config[$key]; |
| 177 | 177 | } |
| 178 | 178 | $this->$key = $value; |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function setEventsFromConfig($config) { |
| 186 | 186 | $this->events = ClientManager::get("events"); |
| 187 | - if(isset($config['events'])){ |
|
| 188 | - if(isset($config['events'])) { |
|
| 189 | - foreach($config['events'] as $section => $events) { |
|
| 187 | + if (isset($config['events'])) { |
|
| 188 | + if (isset($config['events'])) { |
|
| 189 | + foreach ($config['events'] as $section => $events) { |
|
| 190 | 190 | $this->events[$section] = array_merge($this->events[$section], $events); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -200,45 +200,45 @@ discard block |
||
| 200 | 200 | * @throws MaskNotFoundException |
| 201 | 201 | */ |
| 202 | 202 | protected function setMaskFromConfig($config) { |
| 203 | - $default_config = ClientManager::get("masks"); |
|
| 203 | + $default_config = ClientManager::get("masks"); |
|
| 204 | 204 | |
| 205 | - if(isset($config['masks'])){ |
|
| 206 | - if(isset($config['masks']['message'])) { |
|
| 207 | - if(class_exists($config['masks']['message'])) { |
|
| 205 | + if (isset($config['masks'])) { |
|
| 206 | + if (isset($config['masks']['message'])) { |
|
| 207 | + if (class_exists($config['masks']['message'])) { |
|
| 208 | 208 | $this->default_message_mask = $config['masks']['message']; |
| 209 | - }else{ |
|
| 209 | + }else { |
|
| 210 | 210 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
| 211 | 211 | } |
| 212 | - }else{ |
|
| 213 | - if(class_exists($default_config['message'])) { |
|
| 212 | + }else { |
|
| 213 | + if (class_exists($default_config['message'])) { |
|
| 214 | 214 | $this->default_message_mask = $default_config['message']; |
| 215 | - }else{ |
|
| 215 | + }else { |
|
| 216 | 216 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | - if(isset($config['masks']['attachment'])) { |
|
| 220 | - if(class_exists($config['masks']['attachment'])) { |
|
| 219 | + if (isset($config['masks']['attachment'])) { |
|
| 220 | + if (class_exists($config['masks']['attachment'])) { |
|
| 221 | 221 | $this->default_message_mask = $config['masks']['attachment']; |
| 222 | - }else{ |
|
| 222 | + }else { |
|
| 223 | 223 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
| 224 | 224 | } |
| 225 | - }else{ |
|
| 226 | - if(class_exists($default_config['attachment'])) { |
|
| 225 | + }else { |
|
| 226 | + if (class_exists($default_config['attachment'])) { |
|
| 227 | 227 | $this->default_message_mask = $default_config['attachment']; |
| 228 | - }else{ |
|
| 228 | + }else { |
|
| 229 | 229 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | - }else{ |
|
| 233 | - if(class_exists($default_config['message'])) { |
|
| 232 | + }else { |
|
| 233 | + if (class_exists($default_config['message'])) { |
|
| 234 | 234 | $this->default_message_mask = $default_config['message']; |
| 235 | - }else{ |
|
| 235 | + }else { |
|
| 236 | 236 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - if(class_exists($default_config['attachment'])) { |
|
| 239 | + if (class_exists($default_config['attachment'])) { |
|
| 240 | 240 | $this->default_message_mask = $default_config['attachment']; |
| 241 | - }else{ |
|
| 241 | + }else { |
|
| 242 | 242 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | $timeout = $this->connection !== false ? $this->connection->getConnectionTimeout() : null; |
| 303 | 303 | $this->connection = new ImapProtocol($this->validate_cert); |
| 304 | 304 | $this->connection->setConnectionTimeout($timeout); |
| 305 | - }else{ |
|
| 305 | + }else { |
|
| 306 | 306 | if (extension_loaded('imap') === false) { |
| 307 | 307 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
| 308 | 308 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | try { |
| 329 | 329 | if ($this->authentication == "oauth") { |
| 330 | 330 | $this->connection->authenticate($this->username, $this->password); |
| 331 | - }else{ |
|
| 331 | + }else { |
|
| 332 | 332 | $this->connection->login($this->username, $this->password); |
| 333 | 333 | } |
| 334 | 334 | } catch (\Exception $e) { |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
| 379 | 379 | $items = $this->connection->folders('', $pattern); |
| 380 | 380 | |
| 381 | - if(is_array($items)){ |
|
| 381 | + if (is_array($items)) { |
|
| 382 | 382 | foreach ($items as $folder_name => $item) { |
| 383 | 383 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
| 384 | 384 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | return $folders; |
| 396 | - }else{ |
|
| 396 | + }else { |
|
| 397 | 397 | throw new FolderFetchingException("failed to fetch any folders"); |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -427,10 +427,10 @@ discard block |
||
| 427 | 427 | public function createFolder($folder, $expunge = true) { |
| 428 | 428 | $this->checkConnection(); |
| 429 | 429 | $status = $this->connection->createFolder($folder); |
| 430 | - if($expunge) $this->expunge(); |
|
| 430 | + if ($expunge) $this->expunge(); |
|
| 431 | 431 | |
| 432 | 432 | $folder = $this->getFolder($folder); |
| 433 | - if($status && $folder) { |
|
| 433 | + if ($status && $folder) { |
|
| 434 | 434 | $event = $this->getEvent("folder", "new"); |
| 435 | 435 | $event::dispatch($folder); |
| 436 | 436 | } |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | * |
| 455 | 455 | * @return Folder |
| 456 | 456 | */ |
| 457 | - public function getFolderPath(){ |
|
| 457 | + public function getFolderPath() { |
|
| 458 | 458 | return $this->active_folder; |
| 459 | 459 | } |
| 460 | 460 | |
@@ -509,14 +509,14 @@ discard block |
||
| 509 | 509 | * |
| 510 | 510 | * @return int |
| 511 | 511 | */ |
| 512 | - public function getTimeout($type){ |
|
| 512 | + public function getTimeout($type) { |
|
| 513 | 513 | return $this->connection->getConnectionTimeout(); |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
| 517 | 517 | * @return string |
| 518 | 518 | */ |
| 519 | - public function getDefaultMessageMask(){ |
|
| 519 | + public function getDefaultMessageMask() { |
|
| 520 | 520 | return $this->default_message_mask; |
| 521 | 521 | } |
| 522 | 522 | |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | * @param $section |
| 525 | 525 | * @return array |
| 526 | 526 | */ |
| 527 | - public function getDefaultEvents($section){ |
|
| 527 | + public function getDefaultEvents($section) { |
|
| 528 | 528 | return $this->events[$section]; |
| 529 | 529 | } |
| 530 | 530 | |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | * @throws MaskNotFoundException |
| 536 | 536 | */ |
| 537 | 537 | public function setDefaultMessageMask($mask) { |
| 538 | - if(class_exists($mask)) { |
|
| 538 | + if (class_exists($mask)) { |
|
| 539 | 539 | $this->default_message_mask = $mask; |
| 540 | 540 | |
| 541 | 541 | return $this; |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | /** |
| 548 | 548 | * @return string |
| 549 | 549 | */ |
| 550 | - public function getDefaultAttachmentMask(){ |
|
| 550 | + public function getDefaultAttachmentMask() { |
|
| 551 | 551 | return $this->default_attachment_mask; |
| 552 | 552 | } |
| 553 | 553 | |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | * @throws MaskNotFoundException |
| 559 | 559 | */ |
| 560 | 560 | public function setDefaultAttachmentMask($mask) { |
| 561 | - if(class_exists($mask)) { |
|
| 561 | + if (class_exists($mask)) { |
|
| 562 | 562 | $this->default_attachment_mask = $mask; |
| 563 | 563 | |
| 564 | 564 | return $this; |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $value = $this->default_account_config[$key]; |
| 173 | 173 | if(isset($config[$key])) { |
| 174 | 174 | $value = $config[$key]; |
| 175 | - }elseif(isset($default_config[$key])) { |
|
| 175 | + } elseif(isset($default_config[$key])) { |
|
| 176 | 176 | $value = $default_config[$key]; |
| 177 | 177 | } |
| 178 | 178 | $this->$key = $value; |
@@ -206,39 +206,39 @@ discard block |
||
| 206 | 206 | if(isset($config['masks']['message'])) { |
| 207 | 207 | if(class_exists($config['masks']['message'])) { |
| 208 | 208 | $this->default_message_mask = $config['masks']['message']; |
| 209 | - }else{ |
|
| 209 | + } else{ |
|
| 210 | 210 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
| 211 | 211 | } |
| 212 | - }else{ |
|
| 212 | + } else{ |
|
| 213 | 213 | if(class_exists($default_config['message'])) { |
| 214 | 214 | $this->default_message_mask = $default_config['message']; |
| 215 | - }else{ |
|
| 215 | + } else{ |
|
| 216 | 216 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | if(isset($config['masks']['attachment'])) { |
| 220 | 220 | if(class_exists($config['masks']['attachment'])) { |
| 221 | 221 | $this->default_message_mask = $config['masks']['attachment']; |
| 222 | - }else{ |
|
| 222 | + } else{ |
|
| 223 | 223 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
| 224 | 224 | } |
| 225 | - }else{ |
|
| 225 | + } else{ |
|
| 226 | 226 | if(class_exists($default_config['attachment'])) { |
| 227 | 227 | $this->default_message_mask = $default_config['attachment']; |
| 228 | - }else{ |
|
| 228 | + } else{ |
|
| 229 | 229 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | - }else{ |
|
| 232 | + } else{ |
|
| 233 | 233 | if(class_exists($default_config['message'])) { |
| 234 | 234 | $this->default_message_mask = $default_config['message']; |
| 235 | - }else{ |
|
| 235 | + } else{ |
|
| 236 | 236 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | if(class_exists($default_config['attachment'])) { |
| 240 | 240 | $this->default_message_mask = $default_config['attachment']; |
| 241 | - }else{ |
|
| 241 | + } else{ |
|
| 242 | 242 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | $timeout = $this->connection !== false ? $this->connection->getConnectionTimeout() : null; |
| 303 | 303 | $this->connection = new ImapProtocol($this->validate_cert); |
| 304 | 304 | $this->connection->setConnectionTimeout($timeout); |
| 305 | - }else{ |
|
| 305 | + } else{ |
|
| 306 | 306 | if (extension_loaded('imap') === false) { |
| 307 | 307 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
| 308 | 308 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | try { |
| 329 | 329 | if ($this->authentication == "oauth") { |
| 330 | 330 | $this->connection->authenticate($this->username, $this->password); |
| 331 | - }else{ |
|
| 331 | + } else{ |
|
| 332 | 332 | $this->connection->login($this->username, $this->password); |
| 333 | 333 | } |
| 334 | 334 | } catch (\Exception $e) { |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | return $folders; |
| 396 | - }else{ |
|
| 396 | + } else{ |
|
| 397 | 397 | throw new FolderFetchingException("failed to fetch any folders"); |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -427,7 +427,9 @@ discard block |
||
| 427 | 427 | public function createFolder($folder, $expunge = true) { |
| 428 | 428 | $this->checkConnection(); |
| 429 | 429 | $status = $this->connection->createFolder($folder); |
| 430 | - if($expunge) $this->expunge(); |
|
| 430 | + if($expunge) { |
|
| 431 | + $this->expunge(); |
|
| 432 | + } |
|
| 431 | 433 | |
| 432 | 434 | $folder = $this->getFolder($folder); |
| 433 | 435 | if($status && $folder) { |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | * @throws MethodNotFoundException |
| 67 | 67 | */ |
| 68 | 68 | public function __call($method, $arguments) { |
| 69 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 69 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 70 | 70 | $name = Str::snake(substr($method, 3)); |
| 71 | 71 | |
| 72 | - if(in_array($name, array_keys($this->attributes))) { |
|
| 72 | + if (in_array($name, array_keys($this->attributes))) { |
|
| 73 | 73 | return $this->attributes[$name]; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @return mixed|null |
| 94 | 94 | */ |
| 95 | 95 | public function get($name) { |
| 96 | - if(isset($this->attributes[$name])) { |
|
| 96 | + if (isset($this->attributes[$name])) { |
|
| 97 | 97 | return $this->attributes[$name]; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | public function find($pattern) { |
| 109 | 109 | if (preg_match_all($pattern, $this->raw, $matches)) { |
| 110 | 110 | if (isset($matches[1])) { |
| 111 | - if(count($matches[1]) > 0) { |
|
| 111 | + if (count($matches[1]) > 0) { |
|
| 112 | 112 | return $matches[1][0]; |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * Parse the raw headers |
| 121 | 121 | * @throws InvalidMessageDateException |
| 122 | 122 | */ |
| 123 | - protected function parse(){ |
|
| 123 | + protected function parse() { |
|
| 124 | 124 | $header = $this->rfc822_parse_headers($this->raw); |
| 125 | 125 | |
| 126 | 126 | $this->extractAddresses($header); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $this->parseDate($header); |
| 139 | 139 | foreach ($header as $key => $value) { |
| 140 | 140 | $key = trim(rtrim(strtolower($key))); |
| 141 | - if(!isset($this->attributes[$key])){ |
|
| 141 | + if (!isset($this->attributes[$key])) { |
|
| 142 | 142 | $this->attributes[$key] = $value; |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * |
| 155 | 155 | * @return object |
| 156 | 156 | */ |
| 157 | - public function rfc822_parse_headers($raw_headers){ |
|
| 157 | + public function rfc822_parse_headers($raw_headers) { |
|
| 158 | 158 | $headers = []; |
| 159 | 159 | $imap_headers = []; |
| 160 | 160 | if (extension_loaded('imap')) { |
@@ -163,13 +163,13 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $lines = explode("\r\n", $raw_headers); |
| 165 | 165 | $prev_header = null; |
| 166 | - foreach($lines as $line) { |
|
| 166 | + foreach ($lines as $line) { |
|
| 167 | 167 | if (substr($line, 0, 1) === "\t") { |
| 168 | 168 | $line = substr($line, 2); |
| 169 | 169 | if ($prev_header !== null) { |
| 170 | 170 | $headers[$prev_header][] = $line; |
| 171 | 171 | } |
| 172 | - }else{ |
|
| 172 | + }else { |
|
| 173 | 173 | if (($pos = strpos($line, ":")) > 0) { |
| 174 | 174 | $key = strtolower(substr($line, 0, $pos)); |
| 175 | 175 | $value = trim(rtrim(strtolower(substr($line, $pos + 1)))); |
@@ -179,10 +179,10 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - foreach($headers as $key => $values) { |
|
| 182 | + foreach ($headers as $key => $values) { |
|
| 183 | 183 | if (isset($imap_headers[$key])) continue; |
| 184 | 184 | $value = null; |
| 185 | - switch($key){ |
|
| 185 | + switch ($key) { |
|
| 186 | 186 | case 'from': |
| 187 | 187 | case 'to': |
| 188 | 188 | case 'cc': |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | * @return array The decoded elements are returned in an array of objects, where each |
| 210 | 210 | * object has two properties, charset and text. |
| 211 | 211 | */ |
| 212 | - public function mime_header_decode($text){ |
|
| 212 | + public function mime_header_decode($text) { |
|
| 213 | 213 | if (extension_loaded('imap')) { |
| 214 | 214 | return \imap_mime_header_decode($text); |
| 215 | 215 | } |
| 216 | 216 | $charset = $this->getEncoding($text); |
| 217 | - return [(object)[ |
|
| 217 | + return [(object) [ |
|
| 218 | 218 | "charset" => $charset, |
| 219 | 219 | "text" => $this->convertEncoding($text, $charset) |
| 220 | 220 | ]]; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | try { |
| 269 | 269 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
| 270 | 270 | return iconv($from, $to, $str); |
| 271 | - } else { |
|
| 271 | + }else { |
|
| 272 | 272 | if (!$from) { |
| 273 | 273 | return mb_convert_encoding($str, $to); |
| 274 | 274 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | if (strstr($from, '-')) { |
| 279 | 279 | $from = str_replace('-', '', $from); |
| 280 | 280 | return $this->convertEncoding($str, $from, $to); |
| 281 | - } else { |
|
| 281 | + }else { |
|
| 282 | 282 | return $str; |
| 283 | 283 | } |
| 284 | 284 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | }elseif (property_exists($structure, 'charset')) { |
| 302 | 302 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
| 303 | - }elseif (is_string($structure) === true){ |
|
| 303 | + }elseif (is_string($structure) === true) { |
|
| 304 | 304 | return mb_detect_encoding($structure); |
| 305 | 305 | } |
| 306 | 306 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | $decoder = $this->config['decoder']['message']; |
| 319 | 319 | |
| 320 | 320 | if ($value !== null) { |
| 321 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 321 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 322 | 322 | $value = \imap_utf8($value); |
| 323 | 323 | if (Str::startsWith(mb_strtolower($value), '=?utf-8?')) { |
| 324 | 324 | $value = mb_decode_mimeheader($value); |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | if ($this->notDecoded($original_value, $value)) { |
| 327 | 327 | $value = $this->mime_header_decode(imap_utf8($value)); |
| 328 | 328 | } |
| 329 | - }elseif($decoder === 'iconv') { |
|
| 329 | + }elseif ($decoder === 'iconv') { |
|
| 330 | 330 | $value = iconv_mime_decode($value); |
| 331 | - }else{ |
|
| 331 | + }else { |
|
| 332 | 332 | $value = mb_decode_mimeheader($value); |
| 333 | 333 | } |
| 334 | 334 | |
@@ -344,8 +344,8 @@ discard block |
||
| 344 | 344 | * Try to extract the priority from a given raw header string |
| 345 | 345 | */ |
| 346 | 346 | private function findPriority() { |
| 347 | - if(($priority = $this->get("x-priority")) === null) return; |
|
| 348 | - switch($priority){ |
|
| 347 | + if (($priority = $this->get("x-priority")) === null) return; |
|
| 348 | + switch ($priority) { |
|
| 349 | 349 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 350 | 350 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 351 | 351 | break; |
@@ -377,12 +377,12 @@ discard block |
||
| 377 | 377 | */ |
| 378 | 378 | private function decodeAddresses($values) { |
| 379 | 379 | $addresses = []; |
| 380 | - foreach($values as $address) { |
|
| 380 | + foreach ($values as $address) { |
|
| 381 | 381 | if (preg_match( |
| 382 | 382 | '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/', |
| 383 | 383 | $address, |
| 384 | 384 | $matches |
| 385 | - )){ |
|
| 385 | + )) { |
|
| 386 | 386 | $name = trim(rtrim($matches["name"])); |
| 387 | 387 | $email = trim(rtrim($matches["email"])); |
| 388 | 388 | list($mailbox, $host) = explode("@", $email); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * @param object $header |
| 402 | 402 | */ |
| 403 | 403 | private function extractAddresses($header) { |
| 404 | - foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender', 'in_reply_to'] as $key){ |
|
| 404 | + foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender', 'in_reply_to'] as $key) { |
|
| 405 | 405 | if (property_exists($header, $key)) { |
| 406 | 406 | $this->attributes[$key] = $this->parseAddresses($header->$key); |
| 407 | 407 | } |
@@ -428,10 +428,10 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | if (!property_exists($address, 'personal')) { |
| 430 | 430 | $address->personal = false; |
| 431 | - } else { |
|
| 431 | + }else { |
|
| 432 | 432 | $personalParts = $this->mime_header_decode($address->personal); |
| 433 | 433 | |
| 434 | - if(is_array($personalParts)) { |
|
| 434 | + if (is_array($personalParts)) { |
|
| 435 | 435 | $address->personal = ''; |
| 436 | 436 | foreach ($personalParts as $p) { |
| 437 | 437 | $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p)); |
@@ -448,15 +448,15 @@ discard block |
||
| 448 | 448 | return $addresses; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | - private function extractHeaderExtensions(){ |
|
| 451 | + private function extractHeaderExtensions() { |
|
| 452 | 452 | foreach ($this->attributes as $key => $value) { |
| 453 | 453 | if (is_string($value) === true) { |
| 454 | - if (($pos = strpos($value, ";")) !== false){ |
|
| 454 | + if (($pos = strpos($value, ";")) !== false) { |
|
| 455 | 455 | $original = substr($value, 0, $pos); |
| 456 | 456 | $this->attributes[$key] = trim(rtrim($original)); |
| 457 | 457 | $extensions = explode(";", substr($value, $pos + 1)); |
| 458 | - foreach($extensions as $extension) { |
|
| 459 | - if (($pos = strpos($extension, "=")) !== false){ |
|
| 458 | + foreach ($extensions as $extension) { |
|
| 459 | + if (($pos = strpos($extension, "=")) !== false) { |
|
| 460 | 460 | $key = substr($extension, 0, $pos); |
| 461 | 461 | $value = substr($extension, $pos + 1); |
| 462 | 462 | $this->attributes[trim(rtrim(strtolower($key)))] = trim(rtrim($value)); |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | $parsed_date = null; |
| 493 | 493 | $date = $header->date; |
| 494 | 494 | |
| 495 | - if(preg_match('/\+0580/', $date)) { |
|
| 495 | + if (preg_match('/\+0580/', $date)) { |
|
| 496 | 496 | $date = str_replace('+0580', '+0530', $date); |
| 497 | 497 | } |
| 498 | 498 | |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $date = trim(array_pop($array)); |
| 516 | 516 | break; |
| 517 | 517 | } |
| 518 | - try{ |
|
| 518 | + try { |
|
| 519 | 519 | $parsed_date = Carbon::parse($date); |
| 520 | 520 | } catch (\Exception $_e) { |
| 521 | 521 | throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | if ($prev_header !== null) { |
| 170 | 170 | $headers[$prev_header][] = $line; |
| 171 | 171 | } |
| 172 | - }else{ |
|
| 172 | + } else{ |
|
| 173 | 173 | if (($pos = strpos($line, ":")) > 0) { |
| 174 | 174 | $key = strtolower(substr($line, 0, $pos)); |
| 175 | 175 | $value = trim(rtrim(strtolower(substr($line, $pos + 1)))); |
@@ -180,7 +180,9 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | foreach($headers as $key => $values) { |
| 183 | - if (isset($imap_headers[$key])) continue; |
|
| 183 | + if (isset($imap_headers[$key])) { |
|
| 184 | + continue; |
|
| 185 | + } |
|
| 184 | 186 | $value = null; |
| 185 | 187 | switch($key){ |
| 186 | 188 | case 'from': |
@@ -298,9 +300,9 @@ discard block |
||
| 298 | 300 | return EncodingAliases::get($parameter->value, $this->fallback_encoding); |
| 299 | 301 | } |
| 300 | 302 | } |
| 301 | - }elseif (property_exists($structure, 'charset')) { |
|
| 303 | + } elseif (property_exists($structure, 'charset')) { |
|
| 302 | 304 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
| 303 | - }elseif (is_string($structure) === true){ |
|
| 305 | + } elseif (is_string($structure) === true){ |
|
| 304 | 306 | return mb_detect_encoding($structure); |
| 305 | 307 | } |
| 306 | 308 | |
@@ -326,9 +328,9 @@ discard block |
||
| 326 | 328 | if ($this->notDecoded($original_value, $value)) { |
| 327 | 329 | $value = $this->mime_header_decode(imap_utf8($value)); |
| 328 | 330 | } |
| 329 | - }elseif($decoder === 'iconv') { |
|
| 331 | + } elseif($decoder === 'iconv') { |
|
| 330 | 332 | $value = iconv_mime_decode($value); |
| 331 | - }else{ |
|
| 333 | + } else{ |
|
| 332 | 334 | $value = mb_decode_mimeheader($value); |
| 333 | 335 | } |
| 334 | 336 | |
@@ -344,7 +346,9 @@ discard block |
||
| 344 | 346 | * Try to extract the priority from a given raw header string |
| 345 | 347 | */ |
| 346 | 348 | private function findPriority() { |
| 347 | - if(($priority = $this->get("x-priority")) === null) return; |
|
| 349 | + if(($priority = $this->get("x-priority")) === null) { |
|
| 350 | + return; |
|
| 351 | + } |
|
| 348 | 352 | switch($priority){ |
| 349 | 353 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 350 | 354 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |