@@ -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 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * @return WhereQuery |
422 | 422 | * @throws InvalidWhereQueryCriteriaException |
423 | 423 | */ |
424 | - public function whereHeader($header, $value){ |
|
424 | + public function whereHeader($header, $value) { |
|
425 | 425 | return $this->where("CUSTOM HEADER $header $value"); |
426 | 426 | } |
427 | 427 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @return WhereQuery |
433 | 433 | * @throws InvalidWhereQueryCriteriaException |
434 | 434 | */ |
435 | - public function whereMessageId($messageId){ |
|
435 | + public function whereMessageId($messageId) { |
|
436 | 436 | return $this->whereHeader("Message-ID", $messageId); |
437 | 437 | } |
438 | 438 | |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * @return WhereQuery |
444 | 444 | * @throws InvalidWhereQueryCriteriaException |
445 | 445 | */ |
446 | - public function whereInReplyTo($messageId){ |
|
446 | + public function whereInReplyTo($messageId) { |
|
447 | 447 | return $this->whereHeader("In-Reply-To", $messageId); |
448 | 448 | } |
449 | 449 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @return WhereQuery |
454 | 454 | * @throws InvalidWhereQueryCriteriaException |
455 | 455 | */ |
456 | - public function whereLanguage($country_code){ |
|
456 | + public function whereLanguage($country_code) { |
|
457 | 457 | return $this->where("Content-Language $country_code"); |
458 | 458 | } |
459 | 459 | } |
460 | 460 | \ No newline at end of file |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | public function __construct(Client $client, $charset = 'UTF-8') { |
77 | 77 | $this->setClient($client); |
78 | 78 | |
79 | - if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
79 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
80 | 80 | |
81 | 81 | if (ClientManager::get('options.fetch_order') === 'desc') { |
82 | 82 | $this->fetch_order = 'desc'; |
83 | - } else { |
|
83 | + }else { |
|
84 | 84 | $this->fetch_order = 'asc'; |
85 | 85 | } |
86 | 86 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * Instance boot method for additional functionality |
96 | 96 | */ |
97 | - protected function boot(){} |
|
97 | + protected function boot() {} |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Parse a given value |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return string |
104 | 104 | */ |
105 | - protected function parse_value($value){ |
|
106 | - switch(true){ |
|
105 | + protected function parse_value($value) { |
|
106 | + switch (true) { |
|
107 | 107 | case $value instanceof \Carbon\Carbon: |
108 | 108 | $value = $value->format($this->date_format); |
109 | 109 | break; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @throws MessageSearchValidationException |
121 | 121 | */ |
122 | 122 | protected function parse_date($date) { |
123 | - if($date instanceof \Carbon\Carbon) return $date; |
|
123 | + if ($date instanceof \Carbon\Carbon) return $date; |
|
124 | 124 | |
125 | 125 | try { |
126 | 126 | $date = Carbon::parse($date); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @return Collection |
160 | 160 | * @throws GetMessagesFailedException |
161 | 161 | */ |
162 | - protected function search(){ |
|
162 | + protected function search() { |
|
163 | 163 | $this->generate_query(); |
164 | 164 | |
165 | 165 | try { |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $raw_flag = isset($raw_flags[$msgno]) ? $raw_flags[$msgno] : []; |
228 | 228 | |
229 | 229 | $message = Message::make($msgno, $msglist, $this->getClient(), $raw_header, $raw_content, $raw_flag, $this->getFetchOptions()); |
230 | - switch ($message_key){ |
|
230 | + switch ($message_key) { |
|
231 | 231 | case 'number': |
232 | 232 | $message_key = $message->getMessageNo(); |
233 | 233 | break; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | return $messages; |
248 | 248 | } catch (\Exception $e) { |
249 | - throw new GetMessagesFailedException($e->getMessage(),0, $e); |
|
249 | + throw new GetMessagesFailedException($e->getMessage(), 0, $e); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @throws MessageHeaderFetchingException |
264 | 264 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
265 | 265 | */ |
266 | - public function getMessage($msgno, $msglist = null){ |
|
266 | + public function getMessage($msgno, $msglist = null) { |
|
267 | 267 | return new Message($msgno, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags()); |
268 | 268 | } |
269 | 269 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @return LengthAwarePaginator |
277 | 277 | * @throws GetMessagesFailedException |
278 | 278 | */ |
279 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
279 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
280 | 280 | if ( |
281 | 281 | $page === null |
282 | 282 | && isset($_GET[$page_name]) |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | $this->query->each(function($statement) use(&$query) { |
303 | 303 | if (count($statement) == 1) { |
304 | 304 | $query .= $statement[0]; |
305 | - } else { |
|
306 | - if($statement[1] === null){ |
|
305 | + }else { |
|
306 | + if ($statement[1] === null) { |
|
307 | 307 | $query .= $statement[0]; |
308 | - }else{ |
|
308 | + }else { |
|
309 | 309 | $query .= $statement[0].' "'.$statement[1].'"'; |
310 | 310 | } |
311 | 311 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * @return $this |
336 | 336 | */ |
337 | 337 | public function limit($limit, $page = 1) { |
338 | - if($page >= 1) $this->page = $page; |
|
338 | + if ($page >= 1) $this->page = $page; |
|
339 | 339 | $this->limit = $limit; |
340 | 340 | |
341 | 341 | return $this; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | throw new AuthFailedException($message); |
86 | 86 | } |
87 | 87 | |
88 | - if(!$this->stream) { |
|
88 | + if (!$this->stream) { |
|
89 | 89 | $errors = \imap_errors(); |
90 | 90 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
91 | 91 | throw new AuthFailedException($message); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | if (!$this->cert_validation) { |
117 | 117 | $address .= '/novalidate-cert'; |
118 | 118 | } |
119 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
119 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
120 | 120 | $address .= '/'.$this->encryption; |
121 | 121 | } elseif ($this->encryption === "starttls") { |
122 | 122 | $address .= '/tls'; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return bool |
146 | 146 | */ |
147 | - public function connected(){ |
|
147 | + public function connected() { |
|
148 | 148 | return !$this->stream; |
149 | 149 | } |
150 | 150 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return array |
216 | 216 | */ |
217 | - public function headers($uids, $rfc = "RFC822"){ |
|
217 | + public function headers($uids, $rfc = "RFC822") { |
|
218 | 218 | $result = []; |
219 | 219 | $uids = is_array($uids) ? $uids : [$uids]; |
220 | 220 | foreach ($uids as $uid) { |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return array |
231 | 231 | */ |
232 | - public function flags($uids){ |
|
232 | + public function flags($uids) { |
|
233 | 233 | $result = []; |
234 | 234 | $uids = is_array($uids) ? $uids : [$uids]; |
235 | 235 | foreach ($uids as $uid) { |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | $flags = []; |
238 | 238 | if (is_array($raw_flags) && isset($raw_flags[0])) { |
239 | 239 | $raw_flags = (array) $raw_flags[0]; |
240 | - foreach($raw_flags as $flag => $value) { |
|
241 | - if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){ |
|
240 | + foreach ($raw_flags as $flag => $value) { |
|
241 | + if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) { |
|
242 | 242 | $flags[] = "\\".ucfirst($flag); |
243 | 243 | } |
244 | 244 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | if ($id === null) { |
260 | 260 | $overview = $this->overview("1:*"); |
261 | 261 | $uids = []; |
262 | - foreach($overview as $set){ |
|
262 | + foreach ($overview as $set) { |
|
263 | 263 | $uids[$set->msgno] = $set->uid; |
264 | 264 | } |
265 | 265 | return $uids; |
@@ -299,12 +299,12 @@ discard block |
||
299 | 299 | $result = []; |
300 | 300 | |
301 | 301 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
302 | - if(is_array($items)){ |
|
302 | + if (is_array($items)) { |
|
303 | 303 | foreach ($items as $item) { |
304 | 304 | $name = $this->decodeFolderName($item->name); |
305 | 305 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
306 | 306 | } |
307 | - }else{ |
|
307 | + }else { |
|
308 | 308 | throw new RuntimeException(\imap_last_error()); |
309 | 309 | } |
310 | 310 | |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true) { |
326 | 326 | $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags); |
327 | 327 | |
328 | - if ($mode == "+"){ |
|
328 | + if ($mode == "+") { |
|
329 | 329 | $status = \imap_setflag_full($this->stream, $from, $flag, IMAP::NIL); |
330 | - }else{ |
|
330 | + }else { |
|
331 | 331 | $status = \imap_clearflag_full($this->stream, $from, $flag, IMAP::NIL); |
332 | 332 | } |
333 | 333 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | */ |
350 | 350 | public function appendMessage($folder, $message, $flags = null, $date = null) { |
351 | 351 | if ($date != null) { |
352 | - if ($date instanceof \Carbon\Carbon){ |
|
352 | + if ($date instanceof \Carbon\Carbon) { |
|
353 | 353 | $date = $date->format('d-M-Y H:i:s O'); |
354 | 354 | } |
355 | 355 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -484,14 +484,14 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * Enable the debug mode |
486 | 486 | */ |
487 | - public function enableDebug(){ |
|
487 | + public function enableDebug() { |
|
488 | 488 | $this->debug = true; |
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
492 | 492 | * Disable the debug mode |
493 | 493 | */ |
494 | - public function disableDebug(){ |
|
494 | + public function disableDebug() { |
|
495 | 495 | $this->debug = false; |
496 | 496 | } |
497 | 497 |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @throws ConnectionFailedException |
84 | 84 | * @throws RuntimeException |
85 | 85 | */ |
86 | - protected function enableTls(){ |
|
86 | + protected function enableTls() { |
|
87 | 87 | $response = $this->requestAndResponse('STARTTLS'); |
88 | 88 | $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod()); |
89 | 89 | if (!$result) { |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $stack = []; |
146 | 146 | |
147 | 147 | // replace any trailing <NL> including spaces with a single space |
148 | - $line = rtrim($line) . ' '; |
|
148 | + $line = rtrim($line).' '; |
|
149 | 149 | while (($pos = strpos($line, ' ')) !== false) { |
150 | 150 | $token = substr($line, 0, $pos); |
151 | 151 | if (!strlen($token)) { |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | if (strlen($token) > $chars) { |
176 | 176 | $line = substr($token, $chars); |
177 | 177 | $token = substr($token, 0, $chars); |
178 | - } else { |
|
178 | + }else { |
|
179 | 179 | $line .= $this->nextLine(); |
180 | 180 | } |
181 | 181 | $tokens[] = $token; |
182 | - $line = trim($line) . ' '; |
|
182 | + $line = trim($line).' '; |
|
183 | 183 | continue; |
184 | 184 | } |
185 | 185 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $line = $this->nextTaggedLine($tag); // get next tag |
230 | 230 | if (!$dontParse) { |
231 | 231 | $tokens = $this->decodeLine($line); |
232 | - } else { |
|
232 | + }else { |
|
233 | 233 | $tokens = $line; |
234 | 234 | } |
235 | 235 | |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | // First two chars are still needed for the response code |
257 | 257 | $tokens = [substr($tokens, 0, 2)]; |
258 | 258 | } |
259 | - if (is_array($lines)){ |
|
259 | + if (is_array($lines)) { |
|
260 | 260 | if ($this->debug) echo "<< ".json_encode($lines)."\n"; |
261 | - }else{ |
|
261 | + }else { |
|
262 | 262 | if ($this->debug) echo "<< ".$lines."\n"; |
263 | 263 | } |
264 | 264 | |
@@ -283,27 +283,27 @@ discard block |
||
283 | 283 | public function sendRequest($command, $tokens = [], &$tag = null) { |
284 | 284 | if (!$tag) { |
285 | 285 | $this->noun++; |
286 | - $tag = 'TAG' . $this->noun; |
|
286 | + $tag = 'TAG'.$this->noun; |
|
287 | 287 | } |
288 | 288 | |
289 | - $line = $tag . ' ' . $command; |
|
289 | + $line = $tag.' '.$command; |
|
290 | 290 | |
291 | 291 | foreach ($tokens as $token) { |
292 | 292 | if (is_array($token)) { |
293 | - if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) { |
|
293 | + if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) { |
|
294 | 294 | throw new RuntimeException('failed to write - connection closed?'); |
295 | 295 | } |
296 | 296 | if (!$this->assumedNextLine('+ ')) { |
297 | 297 | throw new RuntimeException('failed to send literal string'); |
298 | 298 | } |
299 | 299 | $line = $token[1]; |
300 | - } else { |
|
301 | - $line .= ' ' . $token; |
|
300 | + }else { |
|
301 | + $line .= ' '.$token; |
|
302 | 302 | } |
303 | 303 | } |
304 | 304 | if ($this->debug) echo ">> ".$line."\n"; |
305 | 305 | |
306 | - if (fwrite($this->stream, $line . "\r\n") === false) { |
|
306 | + if (fwrite($this->stream, $line."\r\n") === false) { |
|
307 | 307 | throw new RuntimeException('failed to write - connection closed?'); |
308 | 308 | } |
309 | 309 | } |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | public function escapeString($string) { |
334 | 334 | if (func_num_args() < 2) { |
335 | 335 | if (strpos($string, "\n") !== false) { |
336 | - return ['{' . strlen($string) . '}', $string]; |
|
337 | - } else { |
|
338 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
336 | + return ['{'.strlen($string).'}', $string]; |
|
337 | + }else { |
|
338 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | $result = []; |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | } |
361 | 361 | $result[] = $this->escapeList($v); |
362 | 362 | } |
363 | - return '(' . implode(' ', $result) . ')'; |
|
363 | + return '('.implode(' ', $result).')'; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -400,12 +400,12 @@ discard block |
||
400 | 400 | error_log("got an extra server challenge: $response"); |
401 | 401 | // respond with an empty response. |
402 | 402 | $this->sendRequest(''); |
403 | - } else { |
|
403 | + }else { |
|
404 | 404 | if (preg_match('/^NO /i', $response) || |
405 | 405 | preg_match('/^BAD /i', $response)) { |
406 | 406 | error_log("got failure response: $response"); |
407 | 407 | return false; |
408 | - } else if (preg_match("/^OK /i", $response)) { |
|
408 | + }else if (preg_match("/^OK /i", $response)) { |
|
409 | 409 | return true; |
410 | 410 | } |
411 | 411 | } |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * |
439 | 439 | * @return bool |
440 | 440 | */ |
441 | - public function connected(){ |
|
441 | + public function connected() { |
|
442 | 442 | return (boolean) $this->stream; |
443 | 443 | } |
444 | 444 | |
@@ -485,10 +485,10 @@ discard block |
||
485 | 485 | $result[strtolower($tokens[1])] = $tokens[0]; |
486 | 486 | break; |
487 | 487 | case '[UIDVALIDITY': |
488 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
488 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
489 | 489 | break; |
490 | 490 | case '[UIDNEXT': |
491 | - $result['uidnext'] = (int)$tokens[2]; |
|
491 | + $result['uidnext'] = (int) $tokens[2]; |
|
492 | 492 | break; |
493 | 493 | default: |
494 | 494 | // ignore |
@@ -542,17 +542,17 @@ discard block |
||
542 | 542 | if (is_array($from)) { |
543 | 543 | $set = implode(',', $from); |
544 | 544 | } elseif ($to === null) { |
545 | - $set = (int)$from; |
|
545 | + $set = (int) $from; |
|
546 | 546 | } elseif ($to === INF) { |
547 | - $set = (int)$from . ':*'; |
|
548 | - } else { |
|
549 | - $set = (int)$from . ':' . (int)$to; |
|
547 | + $set = (int) $from.':*'; |
|
548 | + }else { |
|
549 | + $set = (int) $from.':'.(int) $to; |
|
550 | 550 | } |
551 | 551 | |
552 | - $items = (array)$items; |
|
552 | + $items = (array) $items; |
|
553 | 553 | $itemList = $this->escapeList($items); |
554 | 554 | |
555 | - $this->sendRequest(($uid ? 'UID ' : '') . 'FETCH', [$set, $itemList], $tag); |
|
555 | + $this->sendRequest(($uid ? 'UID ' : '').'FETCH', [$set, $itemList], $tag); |
|
556 | 556 | |
557 | 557 | $result = []; |
558 | 558 | $tokens = null; // define $tokens variable before first use |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | $count = count($tokens[2]); |
568 | 568 | if ($tokens[2][$count - 2] == 'UID') { |
569 | 569 | $uidKey = $count - 1; |
570 | - } else { |
|
570 | + }else { |
|
571 | 571 | $uidKey = array_search('UID', $tokens[2]) + 1; |
572 | 572 | } |
573 | 573 | } |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | $data = $tokens[2][1]; |
584 | 584 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
585 | 585 | $data = $tokens[2][3]; |
586 | - } else { |
|
586 | + }else { |
|
587 | 587 | // maybe the server send an other field we didn't wanted |
588 | 588 | $count = count($tokens[2]); |
589 | 589 | // we start with 2, because 0 was already checked |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | break; |
596 | 596 | } |
597 | 597 | } |
598 | - } else { |
|
598 | + }else { |
|
599 | 599 | $data = []; |
600 | 600 | while (key($tokens[2]) !== null) { |
601 | 601 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | * @return array |
641 | 641 | * @throws RuntimeException |
642 | 642 | */ |
643 | - public function headers($uids, $rfc = "RFC822"){ |
|
643 | + public function headers($uids, $rfc = "RFC822") { |
|
644 | 644 | return $this->fetch(["$rfc.HEADER"], $uids); |
645 | 645 | } |
646 | 646 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | * @return array |
652 | 652 | * @throws RuntimeException |
653 | 653 | */ |
654 | - public function flags($uids){ |
|
654 | + public function flags($uids) { |
|
655 | 655 | return $this->fetch(["FLAGS"], $uids); |
656 | 656 | } |
657 | 657 | |
@@ -735,22 +735,22 @@ discard block |
||
735 | 735 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true) { |
736 | 736 | $item = 'FLAGS'; |
737 | 737 | if ($mode == '+' || $mode == '-') { |
738 | - $item = $mode . $item; |
|
738 | + $item = $mode.$item; |
|
739 | 739 | } |
740 | 740 | if ($silent) { |
741 | 741 | $item .= '.SILENT'; |
742 | 742 | } |
743 | 743 | |
744 | 744 | $flags = $this->escapeList($flags); |
745 | - $set = (int)$from; |
|
745 | + $set = (int) $from; |
|
746 | 746 | if ($to !== null) { |
747 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
747 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | $result = $this->requestAndResponse('STORE', [$set, $item, $flags], $silent); |
751 | 751 | |
752 | 752 | if ($silent) { |
753 | - return (bool)$result; |
|
753 | + return (bool) $result; |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | $tokens = $result; |
@@ -800,9 +800,9 @@ discard block |
||
800 | 800 | * @throws RuntimeException |
801 | 801 | */ |
802 | 802 | public function copyMessage($folder, $from, $to = null) { |
803 | - $set = (int)$from; |
|
803 | + $set = (int) $from; |
|
804 | 804 | if ($to !== null) { |
805 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
805 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | return $this->requestAndResponse('COPY', [$set, $this->escapeString($folder)], true); |
@@ -819,9 +819,9 @@ discard block |
||
819 | 819 | * @throws RuntimeException |
820 | 820 | */ |
821 | 821 | public function moveMessage($folder, $from, $to = null) { |
822 | - $set = (int)$from; |
|
822 | + $set = (int) $from; |
|
823 | 823 | if ($to !== null) { |
824 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
824 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | return $this->requestAndResponse('MOVE', [$set, $this->escapeString($folder)], true); |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | $uids = $this->getUid(); |
985 | 985 | $ids = []; |
986 | 986 | foreach ($uids as $msgn => $v) { |
987 | - if ( ($to >= $msgn && $from <= $msgn) || ($to === "*" && $from <= $msgn) ){ |
|
987 | + if (($to >= $msgn && $from <= $msgn) || ($to === "*" && $from <= $msgn)) { |
|
988 | 988 | $ids[] = $msgn; |
989 | 989 | } |
990 | 990 | } |
@@ -998,14 +998,14 @@ discard block |
||
998 | 998 | /** |
999 | 999 | * Enable the debug mode |
1000 | 1000 | */ |
1001 | - public function enableDebug(){ |
|
1001 | + public function enableDebug() { |
|
1002 | 1002 | $this->debug = true; |
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | /** |
1006 | 1006 | * Disable the debug mode |
1007 | 1007 | */ |
1008 | - public function disableDebug(){ |
|
1008 | + public function disableDebug() { |
|
1009 | 1009 | $this->debug = false; |
1010 | 1010 | } |
1011 | 1011 | } |
1012 | 1012 | \ No newline at end of file |
@@ -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); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $this->parseDate($header); |
153 | 153 | foreach ($header as $key => $value) { |
154 | 154 | $key = trim(rtrim(strtolower($key))); |
155 | - if(!isset($this->attributes[$key])){ |
|
155 | + if (!isset($this->attributes[$key])) { |
|
156 | 156 | $this->attributes[$key] = $value; |
157 | 157 | } |
158 | 158 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return object |
170 | 170 | */ |
171 | - public function rfc822_parse_headers($raw_headers){ |
|
171 | + public function rfc822_parse_headers($raw_headers) { |
|
172 | 172 | $headers = []; |
173 | 173 | $imap_headers = []; |
174 | 174 | if (extension_loaded('imap')) { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $lines = explode("\r\n", $raw_headers); |
179 | 179 | $prev_header = null; |
180 | - foreach($lines as $line) { |
|
180 | + foreach ($lines as $line) { |
|
181 | 181 | if (substr($line, 0, 1) === "\n") { |
182 | 182 | $line = substr($line, 1); |
183 | 183 | } |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | } |
198 | 198 | if (is_array($headers[$prev_header])) { |
199 | 199 | $headers[$prev_header][] = $line; |
200 | - }else{ |
|
200 | + }else { |
|
201 | 201 | $headers[$prev_header] .= $line; |
202 | 202 | } |
203 | 203 | } |
204 | - }else{ |
|
204 | + }else { |
|
205 | 205 | if (($pos = strpos($line, ":")) > 0) { |
206 | 206 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
207 | 207 | $value = trim(rtrim(substr($line, $pos + 1))); |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | - foreach($headers as $key => $values) { |
|
214 | + foreach ($headers as $key => $values) { |
|
215 | 215 | if (isset($imap_headers[$key])) continue; |
216 | 216 | $value = null; |
217 | - switch($key){ |
|
217 | + switch ($key) { |
|
218 | 218 | case 'from': |
219 | 219 | case 'to': |
220 | 220 | case 'cc': |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | break; |
230 | 230 | default: |
231 | 231 | if (is_array($values)) { |
232 | - foreach($values as $k => $v) { |
|
232 | + foreach ($values as $k => $v) { |
|
233 | 233 | if ($v == "") { |
234 | 234 | unset($values[$k]); |
235 | 235 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $value = implode(" ", $values); |
242 | 242 | } elseif ($available_values > 2) { |
243 | 243 | $value = array_values($values); |
244 | - } else { |
|
244 | + }else { |
|
245 | 245 | $value = ""; |
246 | 246 | } |
247 | 247 | } |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | * @return array The decoded elements are returned in an array of objects, where each |
262 | 262 | * object has two properties, charset and text. |
263 | 263 | */ |
264 | - public function mime_header_decode($text){ |
|
264 | + public function mime_header_decode($text) { |
|
265 | 265 | if (extension_loaded('imap')) { |
266 | 266 | return \imap_mime_header_decode($text); |
267 | 267 | } |
268 | 268 | $charset = $this->getEncoding($text); |
269 | - return [(object)[ |
|
269 | + return [(object) [ |
|
270 | 270 | "charset" => $charset, |
271 | 271 | "text" => $this->convertEncoding($text, $charset) |
272 | 272 | ]]; |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | try { |
321 | 321 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
322 | 322 | return iconv($from, $to, $str); |
323 | - } else { |
|
323 | + }else { |
|
324 | 324 | if (!$from) { |
325 | 325 | return mb_convert_encoding($str, $to); |
326 | 326 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | if (strstr($from, '-')) { |
331 | 331 | $from = str_replace('-', '', $from); |
332 | 332 | return $this->convertEncoding($str, $from, $to); |
333 | - } else { |
|
333 | + }else { |
|
334 | 334 | return $str; |
335 | 335 | } |
336 | 336 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | }elseif (property_exists($structure, 'charset')) { |
353 | 353 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
354 | - }elseif (is_string($structure) === true){ |
|
354 | + }elseif (is_string($structure) === true) { |
|
355 | 355 | return mb_detect_encoding($structure); |
356 | 356 | } |
357 | 357 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $decoder = $this->config['decoder']['message']; |
373 | 373 | |
374 | 374 | if ($value !== null) { |
375 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
375 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
376 | 376 | $value = \imap_utf8($value); |
377 | 377 | if (strpos(strtolower($value), '=?utf-8?') === 0) { |
378 | 378 | $value = mb_decode_mimeheader($value); |
@@ -380,14 +380,14 @@ discard block |
||
380 | 380 | if ($this->notDecoded($original_value, $value)) { |
381 | 381 | $decoded_value = $this->mime_header_decode($value); |
382 | 382 | if (count($decoded_value) > 0) { |
383 | - if(property_exists($decoded_value[0], "text")) { |
|
383 | + if (property_exists($decoded_value[0], "text")) { |
|
384 | 384 | $value = $decoded_value[0]->text; |
385 | 385 | } |
386 | 386 | } |
387 | 387 | } |
388 | - }elseif($decoder === 'iconv') { |
|
388 | + }elseif ($decoder === 'iconv') { |
|
389 | 389 | $value = iconv_mime_decode($value); |
390 | - }else{ |
|
390 | + }else { |
|
391 | 391 | $value = mb_decode_mimeheader($value); |
392 | 392 | } |
393 | 393 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @return array |
411 | 411 | */ |
412 | 412 | private function decodeArray($values) { |
413 | - foreach($values as $key => $value) { |
|
413 | + foreach ($values as $key => $value) { |
|
414 | 414 | $values[$key] = $this->decode($value); |
415 | 415 | } |
416 | 416 | return $values; |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | * Try to extract the priority from a given raw header string |
421 | 421 | */ |
422 | 422 | private function findPriority() { |
423 | - if(($priority = $this->get("x-priority")) === null) return; |
|
424 | - switch($priority){ |
|
423 | + if (($priority = $this->get("x-priority")) === null) return; |
|
424 | + switch ($priority) { |
|
425 | 425 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
426 | 426 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
427 | 427 | break; |
@@ -453,12 +453,12 @@ discard block |
||
453 | 453 | */ |
454 | 454 | private function decodeAddresses($values) { |
455 | 455 | $addresses = []; |
456 | - foreach($values as $address) { |
|
456 | + foreach ($values as $address) { |
|
457 | 457 | if (preg_match( |
458 | 458 | '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/', |
459 | 459 | $address, |
460 | 460 | $matches |
461 | - )){ |
|
461 | + )) { |
|
462 | 462 | $name = trim(rtrim($matches["name"])); |
463 | 463 | $email = trim(rtrim($matches["email"])); |
464 | 464 | list($mailbox, $host) = array_pad(explode("@", $email), 2, null); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @param object $header |
478 | 478 | */ |
479 | 479 | private function extractAddresses($header) { |
480 | - foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){ |
|
480 | + foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) { |
|
481 | 481 | if (property_exists($header, $key)) { |
482 | 482 | $this->attributes[$key] = $this->parseAddresses($header->$key); |
483 | 483 | } |
@@ -508,10 +508,10 @@ discard block |
||
508 | 508 | } |
509 | 509 | if (!property_exists($address, 'personal')) { |
510 | 510 | $address->personal = false; |
511 | - } else { |
|
511 | + }else { |
|
512 | 512 | $personalParts = $this->mime_header_decode($address->personal); |
513 | 513 | |
514 | - if(is_array($personalParts)) { |
|
514 | + if (is_array($personalParts)) { |
|
515 | 515 | $address->personal = ''; |
516 | 516 | foreach ($personalParts as $p) { |
517 | 517 | $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p)); |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | /** |
532 | 532 | * Search and extract potential header extensions |
533 | 533 | */ |
534 | - private function extractHeaderExtensions(){ |
|
534 | + private function extractHeaderExtensions() { |
|
535 | 535 | foreach ($this->attributes as $key => $value) { |
536 | 536 | // Only parse strings and don't parse any attributes like the user-agent |
537 | 537 | if (is_string($value) === true && in_array($key, ["user-agent"]) === false) { |
538 | - if (($pos = strpos($value, ";")) !== false){ |
|
538 | + if (($pos = strpos($value, ";")) !== false) { |
|
539 | 539 | $original = substr($value, 0, $pos); |
540 | 540 | $this->attributes[$key] = trim(rtrim($original)); |
541 | 541 | |
542 | 542 | // Get all potential extensions |
543 | 543 | $extensions = explode(";", substr($value, $pos + 1)); |
544 | - foreach($extensions as $extension) { |
|
545 | - if (($pos = strpos($extension, "=")) !== false){ |
|
544 | + foreach ($extensions as $extension) { |
|
545 | + if (($pos = strpos($extension, "=")) !== false) { |
|
546 | 546 | $key = substr($extension, 0, $pos); |
547 | 547 | $key = trim(rtrim(strtolower($key))); |
548 | 548 | |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | $parsed_date = null; |
586 | 586 | $date = $header->date; |
587 | 587 | |
588 | - if(preg_match('/\+0580/', $date)) { |
|
588 | + if (preg_match('/\+0580/', $date)) { |
|
589 | 589 | $date = str_replace('+0580', '+0530', $date); |
590 | 590 | } |
591 | 591 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | $date = trim(array_pop($array)); |
609 | 609 | break; |
610 | 610 | } |
611 | - try{ |
|
611 | + try { |
|
612 | 612 | $parsed_date = Carbon::parse($date); |
613 | 613 | } catch (\Exception $_e) { |
614 | 614 | throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | public function __construct($msgn, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false) { |
196 | 196 | |
197 | 197 | $default_mask = $client->getDefaultMessageMask(); |
198 | - if($default_mask != null) { |
|
198 | + if ($default_mask != null) { |
|
199 | 199 | $this->mask = $default_mask; |
200 | 200 | } |
201 | 201 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -249,13 +249,13 @@ discard block |
||
249 | 249 | * @throws MessageContentFetchingException |
250 | 250 | * @throws \ReflectionException |
251 | 251 | */ |
252 | - public static function make($msgn, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null){ |
|
252 | + public static function make($msgn, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null) { |
|
253 | 253 | $reflection = new \ReflectionClass(self::class); |
254 | 254 | /** @var self $instance */ |
255 | 255 | $instance = $reflection->newInstanceWithoutConstructor(); |
256 | 256 | |
257 | 257 | $default_mask = $client->getDefaultMessageMask(); |
258 | - if($default_mask != null) { |
|
258 | + if ($default_mask != null) { |
|
259 | 259 | $instance->setMask($default_mask); |
260 | 260 | } |
261 | 261 | $instance->setEvents([ |
@@ -301,13 +301,13 @@ discard block |
||
301 | 301 | * @throws MethodNotFoundException |
302 | 302 | */ |
303 | 303 | public function __call($method, $arguments) { |
304 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
304 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
305 | 305 | $name = Str::snake(substr($method, 3)); |
306 | 306 | return $this->get($name); |
307 | 307 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
308 | 308 | $name = Str::snake(substr($method, 3)); |
309 | 309 | |
310 | - if(in_array($name, array_keys($this->attributes))) { |
|
310 | + if (in_array($name, array_keys($this->attributes))) { |
|
311 | 311 | $this->attributes[$name] = array_pop($arguments); |
312 | 312 | |
313 | 313 | return $this->attributes[$name]; |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @return mixed|null |
349 | 349 | */ |
350 | 350 | public function get($name) { |
351 | - if(isset($this->attributes[$name])) { |
|
351 | + if (isset($this->attributes[$name])) { |
|
352 | 352 | return $this->attributes[$name]; |
353 | 353 | } |
354 | 354 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @throws InvalidMessageDateException |
423 | 423 | */ |
424 | - public function parseRawHeader($raw_header){ |
|
424 | + public function parseRawHeader($raw_header) { |
|
425 | 425 | $this->header = new Header($raw_header); |
426 | 426 | } |
427 | 427 | |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | public function parseRawFlags($raw_flags) { |
433 | 433 | $this->flags = FlagCollection::make([]); |
434 | 434 | |
435 | - foreach($raw_flags as $flag) { |
|
436 | - if (strpos($flag, "\\") === 0){ |
|
435 | + foreach ($raw_flags as $flag) { |
|
436 | + if (strpos($flag, "\\") === 0) { |
|
437 | 437 | $flag = substr($flag, 1); |
438 | 438 | } |
439 | 439 | $flag_key = strtolower($flag); |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | |
537 | 537 | if ($part->isAttachment()) { |
538 | 538 | $this->fetchAttachment($part); |
539 | - }else{ |
|
539 | + }else { |
|
540 | 540 | $encoding = $this->getEncoding($part); |
541 | 541 | |
542 | 542 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) { |
575 | 575 | if ($oAttachment->getId() !== null) { |
576 | 576 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
577 | - } else { |
|
577 | + }else { |
|
578 | 578 | $this->attachments->push($oAttachment); |
579 | 579 | } |
580 | 580 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | |
692 | 692 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
693 | 693 | return @iconv($from, $to.'//IGNORE', $str); |
694 | - } else { |
|
694 | + }else { |
|
695 | 695 | if (!$from) { |
696 | 696 | return mb_convert_encoding($str, $to); |
697 | 697 | } |
@@ -712,9 +712,9 @@ discard block |
||
712 | 712 | return EncodingAliases::get($parameter->value); |
713 | 713 | } |
714 | 714 | } |
715 | - }elseif (property_exists($structure, 'charset')){ |
|
715 | + }elseif (property_exists($structure, 'charset')) { |
|
716 | 716 | return EncodingAliases::get($structure->charset); |
717 | - }elseif (is_string($structure) === true){ |
|
717 | + }elseif (is_string($structure) === true) { |
|
718 | 718 | return mb_detect_encoding($structure); |
719 | 719 | } |
720 | 720 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * @throws Exceptions\ConnectionFailedException |
729 | 729 | * @throws Exceptions\FolderFetchingException |
730 | 730 | */ |
731 | - public function getFolder(){ |
|
731 | + public function getFolder() { |
|
732 | 732 | return $this->client->getFolder($this->folder_path); |
733 | 733 | } |
734 | 734 | |
@@ -743,13 +743,13 @@ discard block |
||
743 | 743 | * @throws Exceptions\FolderFetchingException |
744 | 744 | * @throws Exceptions\GetMessagesFailedException |
745 | 745 | */ |
746 | - public function thread($sent_folder = null, &$thread = null, $folder = null){ |
|
746 | + public function thread($sent_folder = null, &$thread = null, $folder = null) { |
|
747 | 747 | $thread = $thread ? $thread : MessageCollection::make([]); |
748 | - $folder = $folder ? $folder : $this->getFolder(); |
|
748 | + $folder = $folder ? $folder : $this->getFolder(); |
|
749 | 749 | $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent")); |
750 | 750 | |
751 | 751 | /** @var Message $message */ |
752 | - foreach($thread as $message) { |
|
752 | + foreach ($thread as $message) { |
|
753 | 753 | if ($message->message_id == $this->message_id) { |
754 | 754 | return $thread; |
755 | 755 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | }); |
771 | 771 | |
772 | 772 | if (is_array($this->in_reply_to)) { |
773 | - foreach($this->in_reply_to as $in_reply_to) { |
|
773 | + foreach ($this->in_reply_to as $in_reply_to) { |
|
774 | 774 | $folder->query()->messageId($in_reply_to) |
775 | 775 | ->setFetchBody($this->getFetchBodyOption()) |
776 | 776 | ->leaveUnread()->get()->each(function($message) use(&$thread, $folder, $sent_folder){ |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | |
816 | 816 | $this->client->openFolder($this->folder_path); |
817 | 817 | if ($this->client->getConnection()->copyMessage($folder->path, $this->msgn) == true) { |
818 | - if($expunge) $this->client->expunge(); |
|
818 | + if ($expunge) $this->client->expunge(); |
|
819 | 819 | |
820 | 820 | $this->client->openFolder($folder->path); |
821 | 821 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | |
858 | 858 | $this->client->openFolder($this->folder_path); |
859 | 859 | if ($this->client->getConnection()->moveMessage($folder->path, $this->msgn) == true) { |
860 | - if($expunge) $this->client->expunge(); |
|
860 | + if ($expunge) $this->client->expunge(); |
|
861 | 861 | |
862 | 862 | $this->client->openFolder($folder->path); |
863 | 863 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | */ |
885 | 885 | public function delete($expunge = true) { |
886 | 886 | $status = $this->setFlag("Deleted"); |
887 | - if($expunge) $this->client->expunge(); |
|
887 | + if ($expunge) $this->client->expunge(); |
|
888 | 888 | |
889 | 889 | $event = $this->getEvent("message", "deleted"); |
890 | 890 | $event::dispatch($this); |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | */ |
904 | 904 | public function restore($expunge = true) { |
905 | 905 | $status = $this->unsetFlag("Deleted"); |
906 | - if($expunge) $this->client->expunge(); |
|
906 | + if ($expunge) $this->client->expunge(); |
|
907 | 907 | |
908 | 908 | $event = $this->getEvent("message", "restored"); |
909 | 909 | $event::dispatch($this); |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | * |
1057 | 1057 | * @return Structure|null |
1058 | 1058 | */ |
1059 | - public function getStructure(){ |
|
1059 | + public function getStructure() { |
|
1060 | 1060 | return $this->structure; |
1061 | 1061 | } |
1062 | 1062 | |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | * |
1083 | 1083 | * @return array |
1084 | 1084 | */ |
1085 | - public function getAttributes(){ |
|
1085 | + public function getAttributes() { |
|
1086 | 1086 | return array_merge($this->attributes, $this->header->getAttributes()); |
1087 | 1087 | } |
1088 | 1088 | |
@@ -1092,8 +1092,8 @@ discard block |
||
1092 | 1092 | * |
1093 | 1093 | * @return $this |
1094 | 1094 | */ |
1095 | - public function setMask($mask){ |
|
1096 | - if(class_exists($mask)){ |
|
1095 | + public function setMask($mask) { |
|
1096 | + if (class_exists($mask)) { |
|
1097 | 1097 | $this->mask = $mask; |
1098 | 1098 | } |
1099 | 1099 | |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | * |
1106 | 1106 | * @return string |
1107 | 1107 | */ |
1108 | - public function getMask(){ |
|
1108 | + public function getMask() { |
|
1109 | 1109 | return $this->mask; |
1110 | 1110 | } |
1111 | 1111 | |
@@ -1116,9 +1116,9 @@ discard block |
||
1116 | 1116 | * @return mixed |
1117 | 1117 | * @throws MaskNotFoundException |
1118 | 1118 | */ |
1119 | - public function mask($mask = null){ |
|
1119 | + public function mask($mask = null) { |
|
1120 | 1120 | $mask = $mask !== null ? $mask : $this->mask; |
1121 | - if(class_exists($mask)){ |
|
1121 | + if (class_exists($mask)) { |
|
1122 | 1122 | return new $mask($this); |
1123 | 1123 | } |
1124 | 1124 | |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | * |
1132 | 1132 | * @return $this |
1133 | 1133 | */ |
1134 | - public function setFolderPath($folder_path){ |
|
1134 | + public function setFolderPath($folder_path) { |
|
1135 | 1135 | $this->folder_path = $folder_path; |
1136 | 1136 | |
1137 | 1137 | return $this; |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | * |
1144 | 1144 | * @return $this |
1145 | 1145 | */ |
1146 | - public function setConfig($config){ |
|
1146 | + public function setConfig($config) { |
|
1147 | 1147 | $this->config = $config; |
1148 | 1148 | |
1149 | 1149 | return $this; |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | * |
1156 | 1156 | * @return $this |
1157 | 1157 | */ |
1158 | - public function setAttachments($attachments){ |
|
1158 | + public function setAttachments($attachments) { |
|
1159 | 1159 | $this->attachments = $attachments; |
1160 | 1160 | |
1161 | 1161 | return $this; |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | * |
1168 | 1168 | * @return $this |
1169 | 1169 | */ |
1170 | - public function setFlags($flags){ |
|
1170 | + public function setFlags($flags) { |
|
1171 | 1171 | $this->flags = $flags; |
1172 | 1172 | |
1173 | 1173 | return $this; |
@@ -1180,7 +1180,7 @@ discard block |
||
1180 | 1180 | * @throws Exceptions\ConnectionFailedException |
1181 | 1181 | * @return $this |
1182 | 1182 | */ |
1183 | - public function setClient($client){ |
|
1183 | + public function setClient($client) { |
|
1184 | 1184 | $this->client = $client; |
1185 | 1185 | $this->client->openFolder($this->folder_path); |
1186 | 1186 | |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | * @throws Exceptions\RuntimeException |
1197 | 1197 | * @return $this |
1198 | 1198 | */ |
1199 | - public function setMsgn($msgn, $msglist = null){ |
|
1199 | + public function setMsgn($msgn, $msglist = null) { |
|
1200 | 1200 | $this->msgn = $msgn; |
1201 | 1201 | $this->msglist = $msglist; |
1202 | 1202 | $this->uid = $this->client->getConnection()->getUid($this->msgn); |
@@ -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"); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @return array |
249 | 249 | * @throws ConnectionFailedException |
250 | 250 | */ |
251 | - public function overview($sequence = null){ |
|
251 | + public function overview($sequence = null) { |
|
252 | 252 | $this->client->openFolder($this->path); |
253 | 253 | $sequence = $sequence === null ? "1:*" : $sequence; |
254 | 254 | return $this->client->getConnection()->overview($sequence); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | |
274 | 274 | if ($internal_date != null) { |
275 | - if ($internal_date instanceof Carbon){ |
|
275 | + if ($internal_date instanceof Carbon) { |
|
276 | 276 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
277 | 277 | } |
278 | 278 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | */ |
307 | 307 | public function delete($expunge = true) { |
308 | 308 | $status = $this->client->getConnection()->deleteFolder($this->path); |
309 | - if($expunge) $this->client->expunge(); |
|
309 | + if ($expunge) $this->client->expunge(); |
|
310 | 310 | |
311 | 311 | $event = $this->getEvent("folder", "deleted"); |
312 | 312 | $event::dispatch($this); |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | try { |
362 | 362 | $line = $connection->nextLine(); |
363 | 363 | if (($pos = strpos($line, "EXISTS")) !== false) { |
364 | - $msgn = (int) substr($line, 2, $pos -2); |
|
364 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
365 | 365 | $connection->done(); |
366 | 366 | |
367 | 367 | $this->client->openFolder($this->path, true); |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | |
374 | 374 | $connection->idle(); |
375 | 375 | } |
376 | - }catch (Exceptions\RuntimeException $e) { |
|
377 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
376 | + } catch (Exceptions\RuntimeException $e) { |
|
377 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
378 | 378 | throw $e; |
379 | 379 | } |
380 | 380 | } |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * Set the delimiter |
417 | 417 | * @param $delimiter |
418 | 418 | */ |
419 | - public function setDelimiter($delimiter){ |
|
420 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
419 | + public function setDelimiter($delimiter) { |
|
420 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
421 | 421 | $delimiter = ClientManager::get('options.delimiter', '/'); |
422 | 422 | } |
423 | 423 |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | * @param array $config |
195 | 195 | * @param array $default_config |
196 | 196 | */ |
197 | - private function setAccountConfig($key, $config, $default_config){ |
|
197 | + private function setAccountConfig($key, $config, $default_config) { |
|
198 | 198 | $value = $this->default_account_config[$key]; |
199 | - if(isset($config[$key])) { |
|
199 | + if (isset($config[$key])) { |
|
200 | 200 | $value = $config[$key]; |
201 | - }elseif(isset($default_config[$key])) { |
|
201 | + }elseif (isset($default_config[$key])) { |
|
202 | 202 | $value = $default_config[$key]; |
203 | 203 | } |
204 | 204 | $this->$key = $value; |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | */ |
211 | 211 | protected function setEventsFromConfig($config) { |
212 | 212 | $this->events = ClientManager::get("events"); |
213 | - if(isset($config['events'])){ |
|
214 | - if(isset($config['events'])) { |
|
215 | - foreach($config['events'] as $section => $events) { |
|
213 | + if (isset($config['events'])) { |
|
214 | + if (isset($config['events'])) { |
|
215 | + foreach ($config['events'] as $section => $events) { |
|
216 | 216 | $this->events[$section] = array_merge($this->events[$section], $events); |
217 | 217 | } |
218 | 218 | } |
@@ -226,45 +226,45 @@ discard block |
||
226 | 226 | * @throws MaskNotFoundException |
227 | 227 | */ |
228 | 228 | protected function setMaskFromConfig($config) { |
229 | - $default_config = ClientManager::get("masks"); |
|
229 | + $default_config = ClientManager::get("masks"); |
|
230 | 230 | |
231 | - if(isset($config['masks'])){ |
|
232 | - if(isset($config['masks']['message'])) { |
|
233 | - if(class_exists($config['masks']['message'])) { |
|
231 | + if (isset($config['masks'])) { |
|
232 | + if (isset($config['masks']['message'])) { |
|
233 | + if (class_exists($config['masks']['message'])) { |
|
234 | 234 | $this->default_message_mask = $config['masks']['message']; |
235 | - }else{ |
|
235 | + }else { |
|
236 | 236 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
237 | 237 | } |
238 | - }else{ |
|
239 | - if(class_exists($default_config['message'])) { |
|
238 | + }else { |
|
239 | + if (class_exists($default_config['message'])) { |
|
240 | 240 | $this->default_message_mask = $default_config['message']; |
241 | - }else{ |
|
241 | + }else { |
|
242 | 242 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
243 | 243 | } |
244 | 244 | } |
245 | - if(isset($config['masks']['attachment'])) { |
|
246 | - if(class_exists($config['masks']['attachment'])) { |
|
245 | + if (isset($config['masks']['attachment'])) { |
|
246 | + if (class_exists($config['masks']['attachment'])) { |
|
247 | 247 | $this->default_message_mask = $config['masks']['attachment']; |
248 | - }else{ |
|
248 | + }else { |
|
249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
250 | 250 | } |
251 | - }else{ |
|
252 | - if(class_exists($default_config['attachment'])) { |
|
251 | + }else { |
|
252 | + if (class_exists($default_config['attachment'])) { |
|
253 | 253 | $this->default_message_mask = $default_config['attachment']; |
254 | - }else{ |
|
254 | + }else { |
|
255 | 255 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
256 | 256 | } |
257 | 257 | } |
258 | - }else{ |
|
259 | - if(class_exists($default_config['message'])) { |
|
258 | + }else { |
|
259 | + if (class_exists($default_config['message'])) { |
|
260 | 260 | $this->default_message_mask = $default_config['message']; |
261 | - }else{ |
|
261 | + }else { |
|
262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
263 | 263 | } |
264 | 264 | |
265 | - if(class_exists($default_config['attachment'])) { |
|
265 | + if (class_exists($default_config['attachment'])) { |
|
266 | 266 | $this->default_message_mask = $default_config['attachment']; |
267 | - }else{ |
|
267 | + }else { |
|
268 | 268 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
269 | 269 | } |
270 | 270 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
330 | 330 | $this->connection->setConnectionTimeout($timeout); |
331 | 331 | $this->connection->setProxy($this->proxy); |
332 | - }else{ |
|
332 | + }else { |
|
333 | 333 | if (extension_loaded('imap') === false) { |
334 | 334 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
335 | 335 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
443 | 443 | $items = $this->connection->folders('', $pattern); |
444 | 444 | |
445 | - if(is_array($items)){ |
|
445 | + if (is_array($items)) { |
|
446 | 446 | foreach ($items as $folder_name => $item) { |
447 | 447 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
448 | 448 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | } |
458 | 458 | |
459 | 459 | return $folders; |
460 | - }else{ |
|
460 | + }else { |
|
461 | 461 | throw new FolderFetchingException("failed to fetch any folders"); |
462 | 462 | } |
463 | 463 | } |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | $this->checkConnection(); |
494 | 494 | $status = $this->connection->createFolder($folder); |
495 | 495 | |
496 | - if($expunge) $this->expunge(); |
|
496 | + if ($expunge) $this->expunge(); |
|
497 | 497 | |
498 | 498 | $folder = $this->getFolder($folder); |
499 | - if($status && $folder) { |
|
499 | + if ($status && $folder) { |
|
500 | 500 | $event = $this->getEvent("folder", "new"); |
501 | 501 | $event::dispatch($folder); |
502 | 502 | } |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return Folder |
523 | 523 | */ |
524 | - public function getFolderPath(){ |
|
524 | + public function getFolderPath() { |
|
525 | 525 | return $this->active_folder; |
526 | 526 | } |
527 | 527 | |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * |
576 | 576 | * @return int |
577 | 577 | */ |
578 | - public function getTimeout($type){ |
|
578 | + public function getTimeout($type) { |
|
579 | 579 | return $this->connection->getConnectionTimeout(); |
580 | 580 | } |
581 | 581 | |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * |
585 | 585 | * @return string |
586 | 586 | */ |
587 | - public function getDefaultMessageMask(){ |
|
587 | + public function getDefaultMessageMask() { |
|
588 | 588 | return $this->default_message_mask; |
589 | 589 | } |
590 | 590 | |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * |
595 | 595 | * @return array |
596 | 596 | */ |
597 | - public function getDefaultEvents($section){ |
|
597 | + public function getDefaultEvents($section) { |
|
598 | 598 | return $this->events[$section]; |
599 | 599 | } |
600 | 600 | |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | * @throws MaskNotFoundException |
607 | 607 | */ |
608 | 608 | public function setDefaultMessageMask($mask) { |
609 | - if(class_exists($mask)) { |
|
609 | + if (class_exists($mask)) { |
|
610 | 610 | $this->default_message_mask = $mask; |
611 | 611 | |
612 | 612 | return $this; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * |
621 | 621 | * @return string |
622 | 622 | */ |
623 | - public function getDefaultAttachmentMask(){ |
|
623 | + public function getDefaultAttachmentMask() { |
|
624 | 624 | return $this->default_attachment_mask; |
625 | 625 | } |
626 | 626 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * @throws MaskNotFoundException |
633 | 633 | */ |
634 | 634 | public function setDefaultAttachmentMask($mask) { |
635 | - if(class_exists($mask)) { |
|
635 | + if (class_exists($mask)) { |
|
636 | 636 | $this->default_attachment_mask = $mask; |
637 | 637 | |
638 | 638 | return $this; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws MessageContentFetchingException |
78 | 78 | * @throws InvalidMessageDateException |
79 | 79 | */ |
80 | - protected function parse(){ |
|
80 | + protected function parse() { |
|
81 | 81 | $this->findContentType(); |
82 | 82 | $this->parts = $this->find_parts(); |
83 | 83 | } |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Determine the message content type |
87 | 87 | */ |
88 | - public function findContentType(){ |
|
88 | + public function findContentType() { |
|
89 | 89 | |
90 | 90 | $content_type = $this->header->get("content-type"); |
91 | 91 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
92 | - if(stripos($content_type, 'multipart') === 0) { |
|
92 | + if (stripos($content_type, 'multipart') === 0) { |
|
93 | 93 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
94 | - }else{ |
|
94 | + }else { |
|
95 | 95 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
96 | 96 | } |
97 | 97 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * Determine the message content type |
101 | 101 | */ |
102 | - public function getBoundary(){ |
|
102 | + public function getBoundary() { |
|
103 | 103 | $boundary = $this->header->find("/boundary=\"?([^\"]*)[\";\s]/"); |
104 | 104 | return str_replace('"', '', $boundary); |
105 | 105 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @throws MessageContentFetchingException |
112 | 112 | * @throws InvalidMessageDateException |
113 | 113 | */ |
114 | - public function find_parts(){ |
|
115 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
116 | - if (($boundary = $this->getBoundary()) === null) { |
|
114 | + public function find_parts() { |
|
115 | + if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
116 | + if (($boundary = $this->getBoundary()) === null) { |
|
117 | 117 | throw new MessageContentFetchingException("no content found", 0); |
118 | 118 | } |
119 | 119 | |
@@ -122,21 +122,21 @@ discard block |
||
122 | 122 | ]; |
123 | 123 | |
124 | 124 | if (preg_match("/boundary\=\"?(.*)\"?/", $this->raw, $match) == 1) { |
125 | - if(is_array($match[1])){ |
|
126 | - foreach($match[1] as $matched){ |
|
125 | + if (is_array($match[1])) { |
|
126 | + foreach ($match[1] as $matched) { |
|
127 | 127 | $boundaries[] = str_replace('"', '', $matched); |
128 | 128 | } |
129 | - }else{ |
|
130 | - if(!empty($match[1])) { |
|
129 | + }else { |
|
130 | + if (!empty($match[1])) { |
|
131 | 131 | $boundaries[] = str_replace('"', '', $match[1]); |
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | - $raw_parts = explode( $boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw) ); |
|
136 | + $raw_parts = explode($boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw)); |
|
137 | 137 | $parts = []; |
138 | 138 | $part_number = 0; |
139 | - foreach($raw_parts as $part) { |
|
139 | + foreach ($raw_parts as $part) { |
|
140 | 140 | $part = trim(rtrim($part)); |
141 | 141 | if ($part !== "--") { |
142 | 142 | $parts[] = new Part($part, null, $part_number); |