@@ -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 | } |
@@ -26,8 +26,8 @@ |
||
26 | 26 | </tr> |
27 | 27 | </thead> |
28 | 28 | <tbody> |
29 | - <?php if($paginator->count() > 0): ?> |
|
30 | - <?php foreach($paginator as $message): ?> |
|
29 | + <?php if ($paginator->count() > 0): ?> |
|
30 | + <?php foreach ($paginator as $message): ?> |
|
31 | 31 | <tr> |
32 | 32 | <td><?php echo $message->getUid(); ?></td> |
33 | 33 | <td><?php echo $message->getSubject(); ?></td> |
@@ -35,11 +35,14 @@ |
||
35 | 35 | <td><?php echo $message->getAttachments()->count() > 0 ? 'yes' : 'no'; ?></td> |
36 | 36 | </tr> |
37 | 37 | <?php endforeach; ?> |
38 | - <?php else: ?> |
|
38 | + <?php else { |
|
39 | + : ?> |
|
39 | 40 | <tr> |
40 | 41 | <td colspan="4">No messages found</td> |
41 | 42 | </tr> |
42 | - <?php endif; ?> |
|
43 | + <?php endif; |
|
44 | +} |
|
45 | +?> |
|
43 | 46 | </tbody> |
44 | 47 | </table> |
45 | 48 |
@@ -24,8 +24,8 @@ |
||
24 | 24 | </tr> |
25 | 25 | </thead> |
26 | 26 | <tbody> |
27 | - <?php if($paginator->count() > 0): ?> |
|
28 | - <?php foreach($paginator as $folder): ?> |
|
27 | + <?php if ($paginator->count() > 0): ?> |
|
28 | + <?php foreach ($paginator as $folder): ?> |
|
29 | 29 | <tr> |
30 | 30 | <td><?php echo $folder->name; ?></td> |
31 | 31 | <td><?php echo $folder->search()->unseen()->setFetchBody(false)->count(); ?></td> |
@@ -31,11 +31,14 @@ |
||
31 | 31 | <td><?php echo $folder->search()->unseen()->setFetchBody(false)->count(); ?></td> |
32 | 32 | </tr> |
33 | 33 | <?php endforeach; ?> |
34 | - <?php else: ?> |
|
34 | + <?php else { |
|
35 | + : ?> |
|
35 | 36 | <tr> |
36 | 37 | <td colspan="4">No folders found</td> |
37 | 38 | </tr> |
38 | - <?php endif; ?> |
|
39 | + <?php endif; |
|
40 | +} |
|
41 | +?> |
|
39 | 42 | </tbody> |
40 | 43 | </table> |
41 | 44 |
@@ -121,7 +121,7 @@ |
||
121 | 121 | protected function parse(){ |
122 | 122 | if ($this->header === null) { |
123 | 123 | $body = $this->findHeaders(); |
124 | - }else{ |
|
124 | + } else{ |
|
125 | 125 | $body = $this->raw; |
126 | 126 | } |
127 | 127 |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @throws InvalidMessageDateException |
161 | 161 | */ |
162 | - protected function parse(){ |
|
162 | + protected function parse() { |
|
163 | 163 | if ($this->header === null) { |
164 | 164 | $body = $this->findHeaders(); |
165 | - }else{ |
|
165 | + }else { |
|
166 | 166 | $body = $this->raw; |
167 | 167 | } |
168 | 168 | |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | $this->name = $this->header->get("name"); |
175 | 175 | $this->filename = $this->header->get("filename"); |
176 | 176 | |
177 | - if(!empty($this->header->get("id"))) { |
|
177 | + if (!empty($this->header->get("id"))) { |
|
178 | 178 | $this->id = $this->header->get("id"); |
179 | - } else if(!empty($this->header->get("x-attachment-id"))){ |
|
179 | + }else if (!empty($this->header->get("x-attachment-id"))) { |
|
180 | 180 | $this->id = $this->header->get("x-attachment-id"); |
181 | - } else if(!empty($this->header->get("content-id"))){ |
|
181 | + }else if (!empty($this->header->get("content-id"))) { |
|
182 | 182 | $this->id = strtr($this->header->get("content-id"), [ |
183 | 183 | '<' => '', |
184 | 184 | '>' => '' |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | $content_types = $this->header->get("content-type"); |
189 | - if(!empty($content_types)){ |
|
189 | + if (!empty($content_types)) { |
|
190 | 190 | $this->subtype = $this->parseSubtype($content_types); |
191 | 191 | $content_type = $content_types; |
192 | 192 | if (is_array($content_types)) { |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @return string |
208 | 208 | * @throws InvalidMessageDateException |
209 | 209 | */ |
210 | - private function findHeaders(){ |
|
210 | + private function findHeaders() { |
|
211 | 211 | $body = $this->raw; |
212 | 212 | while (($pos = strpos($body, "\r\n")) > 0) { |
213 | 213 | $body = substr($body, $pos + 2); |
@@ -226,16 +226,16 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - private function parseSubtype($content_type){ |
|
229 | + private function parseSubtype($content_type) { |
|
230 | 230 | if (is_array($content_type)) { |
231 | - foreach ($content_type as $part){ |
|
232 | - if ((strpos($part, "/")) !== false){ |
|
231 | + foreach ($content_type as $part) { |
|
232 | + if ((strpos($part, "/")) !== false) { |
|
233 | 233 | return $this->parseSubtype($part); |
234 | 234 | } |
235 | 235 | } |
236 | 236 | return null; |
237 | 237 | } |
238 | - if (($pos = strpos($content_type, "/")) !== false){ |
|
238 | + if (($pos = strpos($content_type, "/")) !== false) { |
|
239 | 239 | return substr($content_type, $pos + 1); |
240 | 240 | } |
241 | 241 | return null; |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | /** |
245 | 245 | * Try to parse the disposition if any is present |
246 | 246 | */ |
247 | - private function parseDisposition(){ |
|
247 | + private function parseDisposition() { |
|
248 | 248 | $content_disposition = $this->header->get("content-disposition"); |
249 | - if($content_disposition !== null) { |
|
249 | + if ($content_disposition !== null) { |
|
250 | 250 | $this->ifdisposition = true; |
251 | 251 | $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition; |
252 | 252 | } |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | /** |
256 | 256 | * Try to parse the description if any is present |
257 | 257 | */ |
258 | - private function parseDescription(){ |
|
258 | + private function parseDescription() { |
|
259 | 259 | $content_description = $this->header->get("content-description"); |
260 | - if($content_description !== null) { |
|
260 | + if ($content_description !== null) { |
|
261 | 261 | $this->ifdescription = true; |
262 | 262 | $this->description = $content_description; |
263 | 263 | } |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | /** |
267 | 267 | * Try to parse the encoding if any is present |
268 | 268 | */ |
269 | - private function parseEncoding(){ |
|
269 | + private function parseEncoding() { |
|
270 | 270 | $encoding = $this->header->get("content-transfer-encoding"); |
271 | - if($encoding !== null) { |
|
271 | + if ($encoding !== null) { |
|
272 | 272 | switch (strtolower($encoding)) { |
273 | 273 | case "quoted-printable": |
274 | 274 | $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE; |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | * @param array $config |
177 | 177 | * @param array $default_config |
178 | 178 | */ |
179 | - private function setAccountConfig($key, $config, $default_config){ |
|
179 | + private function setAccountConfig($key, $config, $default_config) { |
|
180 | 180 | $value = $this->default_account_config[$key]; |
181 | - if(isset($config[$key])) { |
|
181 | + if (isset($config[$key])) { |
|
182 | 182 | $value = $config[$key]; |
183 | - }elseif(isset($default_config[$key])) { |
|
183 | + }elseif (isset($default_config[$key])) { |
|
184 | 184 | $value = $default_config[$key]; |
185 | 185 | } |
186 | 186 | $this->$key = $value; |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function setEventsFromConfig($config) { |
194 | 194 | $this->events = ClientManager::get("events"); |
195 | - if(isset($config['events'])){ |
|
196 | - if(isset($config['events'])) { |
|
197 | - foreach($config['events'] as $section => $events) { |
|
195 | + if (isset($config['events'])) { |
|
196 | + if (isset($config['events'])) { |
|
197 | + foreach ($config['events'] as $section => $events) { |
|
198 | 198 | $this->events[$section] = array_merge($this->events[$section], $events); |
199 | 199 | } |
200 | 200 | } |
@@ -208,45 +208,45 @@ discard block |
||
208 | 208 | * @throws MaskNotFoundException |
209 | 209 | */ |
210 | 210 | protected function setMaskFromConfig($config) { |
211 | - $default_config = ClientManager::get("masks"); |
|
211 | + $default_config = ClientManager::get("masks"); |
|
212 | 212 | |
213 | - if(isset($config['masks'])){ |
|
214 | - if(isset($config['masks']['message'])) { |
|
215 | - if(class_exists($config['masks']['message'])) { |
|
213 | + if (isset($config['masks'])) { |
|
214 | + if (isset($config['masks']['message'])) { |
|
215 | + if (class_exists($config['masks']['message'])) { |
|
216 | 216 | $this->default_message_mask = $config['masks']['message']; |
217 | - }else{ |
|
217 | + }else { |
|
218 | 218 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
219 | 219 | } |
220 | - }else{ |
|
221 | - if(class_exists($default_config['message'])) { |
|
220 | + }else { |
|
221 | + if (class_exists($default_config['message'])) { |
|
222 | 222 | $this->default_message_mask = $default_config['message']; |
223 | - }else{ |
|
223 | + }else { |
|
224 | 224 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
225 | 225 | } |
226 | 226 | } |
227 | - if(isset($config['masks']['attachment'])) { |
|
228 | - if(class_exists($config['masks']['attachment'])) { |
|
227 | + if (isset($config['masks']['attachment'])) { |
|
228 | + if (class_exists($config['masks']['attachment'])) { |
|
229 | 229 | $this->default_message_mask = $config['masks']['attachment']; |
230 | - }else{ |
|
230 | + }else { |
|
231 | 231 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
232 | 232 | } |
233 | - }else{ |
|
234 | - if(class_exists($default_config['attachment'])) { |
|
233 | + }else { |
|
234 | + if (class_exists($default_config['attachment'])) { |
|
235 | 235 | $this->default_message_mask = $default_config['attachment']; |
236 | - }else{ |
|
236 | + }else { |
|
237 | 237 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
238 | 238 | } |
239 | 239 | } |
240 | - }else{ |
|
241 | - if(class_exists($default_config['message'])) { |
|
240 | + }else { |
|
241 | + if (class_exists($default_config['message'])) { |
|
242 | 242 | $this->default_message_mask = $default_config['message']; |
243 | - }else{ |
|
243 | + }else { |
|
244 | 244 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
245 | 245 | } |
246 | 246 | |
247 | - if(class_exists($default_config['attachment'])) { |
|
247 | + if (class_exists($default_config['attachment'])) { |
|
248 | 248 | $this->default_message_mask = $default_config['attachment']; |
249 | - }else{ |
|
249 | + }else { |
|
250 | 250 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
251 | 251 | } |
252 | 252 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $timeout = $this->connection !== false ? $this->connection->getConnectionTimeout() : null; |
311 | 311 | $this->connection = new ImapProtocol($this->validate_cert); |
312 | 312 | $this->connection->setConnectionTimeout($timeout); |
313 | - }else{ |
|
313 | + }else { |
|
314 | 314 | if (extension_loaded('imap') === false) { |
315 | 315 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
316 | 316 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
388 | 388 | $items = $this->connection->folders('', $pattern); |
389 | 389 | |
390 | - if(is_array($items)){ |
|
390 | + if (is_array($items)) { |
|
391 | 391 | foreach ($items as $folder_name => $item) { |
392 | 392 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
393 | 393 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | return $folders; |
405 | - }else{ |
|
405 | + }else { |
|
406 | 406 | throw new FolderFetchingException("failed to fetch any folders"); |
407 | 407 | } |
408 | 408 | } |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | public function createFolder($folder, $expunge = true) { |
437 | 437 | $this->checkConnection(); |
438 | 438 | $status = $this->connection->createFolder($folder); |
439 | - if($expunge) $this->expunge(); |
|
439 | + if ($expunge) $this->expunge(); |
|
440 | 440 | |
441 | 441 | $folder = $this->getFolder($folder); |
442 | - if($status && $folder) { |
|
442 | + if ($status && $folder) { |
|
443 | 443 | $event = $this->getEvent("folder", "new"); |
444 | 444 | $event::dispatch($folder); |
445 | 445 | } |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @return Folder |
466 | 466 | */ |
467 | - public function getFolderPath(){ |
|
467 | + public function getFolderPath() { |
|
468 | 468 | return $this->active_folder; |
469 | 469 | } |
470 | 470 | |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * |
519 | 519 | * @return int |
520 | 520 | */ |
521 | - public function getTimeout($type){ |
|
521 | + public function getTimeout($type) { |
|
522 | 522 | return $this->connection->getConnectionTimeout(); |
523 | 523 | } |
524 | 524 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @return string |
529 | 529 | */ |
530 | - public function getDefaultMessageMask(){ |
|
530 | + public function getDefaultMessageMask() { |
|
531 | 531 | return $this->default_message_mask; |
532 | 532 | } |
533 | 533 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @return array |
539 | 539 | */ |
540 | - public function getDefaultEvents($section){ |
|
540 | + public function getDefaultEvents($section) { |
|
541 | 541 | return $this->events[$section]; |
542 | 542 | } |
543 | 543 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * @throws MaskNotFoundException |
550 | 550 | */ |
551 | 551 | public function setDefaultMessageMask($mask) { |
552 | - if(class_exists($mask)) { |
|
552 | + if (class_exists($mask)) { |
|
553 | 553 | $this->default_message_mask = $mask; |
554 | 554 | |
555 | 555 | return $this; |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @return string |
565 | 565 | */ |
566 | - public function getDefaultAttachmentMask(){ |
|
566 | + public function getDefaultAttachmentMask() { |
|
567 | 567 | return $this->default_attachment_mask; |
568 | 568 | } |
569 | 569 | |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @throws MaskNotFoundException |
576 | 576 | */ |
577 | 577 | public function setDefaultAttachmentMask($mask) { |
578 | - if(class_exists($mask)) { |
|
578 | + if (class_exists($mask)) { |
|
579 | 579 | $this->default_attachment_mask = $mask; |
580 | 580 | |
581 | 581 | return $this; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $value = $this->default_account_config[$key]; |
181 | 181 | if(isset($config[$key])) { |
182 | 182 | $value = $config[$key]; |
183 | - }elseif(isset($default_config[$key])) { |
|
183 | + } elseif(isset($default_config[$key])) { |
|
184 | 184 | $value = $default_config[$key]; |
185 | 185 | } |
186 | 186 | $this->$key = $value; |
@@ -214,39 +214,39 @@ discard block |
||
214 | 214 | if(isset($config['masks']['message'])) { |
215 | 215 | if(class_exists($config['masks']['message'])) { |
216 | 216 | $this->default_message_mask = $config['masks']['message']; |
217 | - }else{ |
|
217 | + } else{ |
|
218 | 218 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
219 | 219 | } |
220 | - }else{ |
|
220 | + } else{ |
|
221 | 221 | if(class_exists($default_config['message'])) { |
222 | 222 | $this->default_message_mask = $default_config['message']; |
223 | - }else{ |
|
223 | + } else{ |
|
224 | 224 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
225 | 225 | } |
226 | 226 | } |
227 | 227 | if(isset($config['masks']['attachment'])) { |
228 | 228 | if(class_exists($config['masks']['attachment'])) { |
229 | 229 | $this->default_message_mask = $config['masks']['attachment']; |
230 | - }else{ |
|
230 | + } else{ |
|
231 | 231 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
232 | 232 | } |
233 | - }else{ |
|
233 | + } else{ |
|
234 | 234 | if(class_exists($default_config['attachment'])) { |
235 | 235 | $this->default_message_mask = $default_config['attachment']; |
236 | - }else{ |
|
236 | + } else{ |
|
237 | 237 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
238 | 238 | } |
239 | 239 | } |
240 | - }else{ |
|
240 | + } else{ |
|
241 | 241 | if(class_exists($default_config['message'])) { |
242 | 242 | $this->default_message_mask = $default_config['message']; |
243 | - }else{ |
|
243 | + } else{ |
|
244 | 244 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
245 | 245 | } |
246 | 246 | |
247 | 247 | if(class_exists($default_config['attachment'])) { |
248 | 248 | $this->default_message_mask = $default_config['attachment']; |
249 | - }else{ |
|
249 | + } else{ |
|
250 | 250 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
251 | 251 | } |
252 | 252 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $timeout = $this->connection !== false ? $this->connection->getConnectionTimeout() : null; |
311 | 311 | $this->connection = new ImapProtocol($this->validate_cert); |
312 | 312 | $this->connection->setConnectionTimeout($timeout); |
313 | - }else{ |
|
313 | + } else{ |
|
314 | 314 | if (extension_loaded('imap') === false) { |
315 | 315 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
316 | 316 | } |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | return $folders; |
405 | - }else{ |
|
405 | + } else{ |
|
406 | 406 | throw new FolderFetchingException("failed to fetch any folders"); |
407 | 407 | } |
408 | 408 | } |
@@ -436,7 +436,9 @@ discard block |
||
436 | 436 | public function createFolder($folder, $expunge = true) { |
437 | 437 | $this->checkConnection(); |
438 | 438 | $status = $this->connection->createFolder($folder); |
439 | - if($expunge) $this->expunge(); |
|
439 | + if($expunge) { |
|
440 | + $this->expunge(); |
|
441 | + } |
|
440 | 442 | |
441 | 443 | $folder = $this->getFolder($folder); |
442 | 444 | if($status && $folder) { |
@@ -376,7 +376,7 @@ |
||
376 | 376 | if (strpos($folder_name, $delimiter) !== false) { |
377 | 377 | return $this->getFolderByPath($folder_name); |
378 | 378 | } |
379 | - } |
|
379 | + } |
|
380 | 380 | |
381 | 381 | return $this->getFolderByName($folder_name); |
382 | 382 | } |
@@ -252,7 +252,7 @@ |
||
252 | 252 | */ |
253 | 253 | public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
254 | 254 | if ( |
255 | - $page === null |
|
255 | + $page === null |
|
256 | 256 | && isset($_GET[$page_name]) |
257 | 257 | && $_GET[$page_name] > 0 |
258 | 258 | ) { |
@@ -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); |
@@ -286,7 +290,7 @@ discard block |
||
286 | 290 | } else { |
287 | 291 | if($statement[1] === null){ |
288 | 292 | $query .= $statement[0]; |
289 | - }else{ |
|
293 | + } else{ |
|
290 | 294 | $query .= $statement[0].' "'.$statement[1].'"'; |
291 | 295 | } |
292 | 296 | } |
@@ -316,7 +320,9 @@ discard block |
||
316 | 320 | * @return $this |
317 | 321 | */ |
318 | 322 | public function limit($limit, $page = 1) { |
319 | - if($page >= 1) $this->page = $page; |
|
323 | + if($page >= 1) { |
|
324 | + $this->page = $page; |
|
325 | + } |
|
320 | 326 | $this->limit = $limit; |
321 | 327 | |
322 | 328 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function __construct(Client $client, $charset = 'UTF-8') { |
74 | 74 | $this->setClient($client); |
75 | 75 | |
76 | - if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
76 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
77 | 77 | |
78 | 78 | $this->date_format = ClientManager::get('date_format', 'd M y'); |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Instance boot method for additional functionality |
87 | 87 | */ |
88 | - protected function boot(){} |
|
88 | + protected function boot() {} |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Parse a given value |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return string |
95 | 95 | */ |
96 | - protected function parse_value($value){ |
|
97 | - switch(true){ |
|
96 | + protected function parse_value($value) { |
|
97 | + switch (true) { |
|
98 | 98 | case $value instanceof \Carbon\Carbon: |
99 | 99 | $value = $value->format($this->date_format); |
100 | 100 | break; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @throws MessageSearchValidationException |
112 | 112 | */ |
113 | 113 | protected function parse_date($date) { |
114 | - if($date instanceof \Carbon\Carbon) return $date; |
|
114 | + if ($date instanceof \Carbon\Carbon) return $date; |
|
115 | 115 | |
116 | 116 | try { |
117 | 117 | $date = Carbon::parse($date); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return Collection |
151 | 151 | * @throws GetMessagesFailedException |
152 | 152 | */ |
153 | - protected function search(){ |
|
153 | + protected function search() { |
|
154 | 154 | $this->generate_query(); |
155 | 155 | |
156 | 156 | try { |
@@ -195,15 +195,15 @@ discard block |
||
195 | 195 | |
196 | 196 | $options = ClientManager::get('options'); |
197 | 197 | |
198 | - if(strtolower($options['fetch_order']) === 'desc'){ |
|
198 | + if (strtolower($options['fetch_order']) === 'desc') { |
|
199 | 199 | $available_messages = $available_messages->reverse(); |
200 | 200 | } |
201 | 201 | |
202 | - $query =& $this; |
|
202 | + $query = & $this; |
|
203 | 203 | |
204 | 204 | $available_messages->forPage($this->page, $this->limit)->each(function($msgno, $msglist) use(&$messages, $options, $query) { |
205 | 205 | $message = $query->getMessage($msgno, $msglist); |
206 | - switch ($options['message_key']){ |
|
206 | + switch ($options['message_key']) { |
|
207 | 207 | case 'number': |
208 | 208 | $message_key = $message->getMessageNo(); |
209 | 209 | break; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | return $messages; |
223 | 223 | } catch (\Exception $e) { |
224 | - throw new GetMessagesFailedException($e->getMessage(),0, $e); |
|
224 | + throw new GetMessagesFailedException($e->getMessage(), 0, $e); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @throws MessageHeaderFetchingException |
239 | 239 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
240 | 240 | */ |
241 | - public function getMessage($msgno, $msglist = null){ |
|
241 | + public function getMessage($msgno, $msglist = null) { |
|
242 | 242 | return new Message($msgno, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags()); |
243 | 243 | } |
244 | 244 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return LengthAwarePaginator |
252 | 252 | * @throws GetMessagesFailedException |
253 | 253 | */ |
254 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
254 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
255 | 255 | if ( |
256 | 256 | $page === null |
257 | 257 | && isset($_GET[$page_name]) |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | $this->query->each(function($statement) use(&$query) { |
278 | 278 | if (count($statement) == 1) { |
279 | 279 | $query .= $statement[0]; |
280 | - } else { |
|
281 | - if($statement[1] === null){ |
|
280 | + }else { |
|
281 | + if ($statement[1] === null) { |
|
282 | 282 | $query .= $statement[0]; |
283 | - }else{ |
|
283 | + }else { |
|
284 | 284 | $query .= $statement[0].' "'.$statement[1].'"'; |
285 | 285 | } |
286 | 286 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @return $this |
311 | 311 | */ |
312 | 312 | public function limit($limit, $page = 1) { |
313 | - if($page >= 1) $this->page = $page; |
|
313 | + if ($page >= 1) $this->page = $page; |
|
314 | 314 | $this->limit = $limit; |
315 | 315 | |
316 | 316 | return $this; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $this->part_number = $part->part_number; |
105 | 105 | |
106 | 106 | $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask(); |
107 | - if($default_mask != null) { |
|
107 | + if ($default_mask != null) { |
|
108 | 108 | $this->mask = $default_mask; |
109 | 109 | } |
110 | 110 | |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | * @throws MethodNotFoundException |
122 | 122 | */ |
123 | 123 | public function __call($method, $arguments) { |
124 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
124 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
125 | 125 | $name = Str::snake(substr($method, 3)); |
126 | 126 | |
127 | - if(isset($this->attributes[$name])) { |
|
127 | + if (isset($this->attributes[$name])) { |
|
128 | 128 | return $this->attributes[$name]; |
129 | 129 | } |
130 | 130 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return mixed|null |
161 | 161 | */ |
162 | 162 | public function __get($name) { |
163 | - if(isset($this->attributes[$name])) { |
|
163 | + if (isset($this->attributes[$name])) { |
|
164 | 164 | return $this->attributes[$name]; |
165 | 165 | } |
166 | 166 | |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | $this->setName($name); |
224 | 224 | }elseif (($filename = $this->part->filename) !== null) { |
225 | 225 | $this->setName($filename); |
226 | - } else { |
|
226 | + }else { |
|
227 | 227 | $this->setName("undefined"); |
228 | 228 | } |
229 | 229 | |
230 | 230 | if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) { |
231 | 231 | if ($this->part->ifdescription) { |
232 | 232 | $this->setName($this->part->description); |
233 | - } else { |
|
233 | + }else { |
|
234 | 234 | $this->setName($this->part->subtype); |
235 | 235 | } |
236 | 236 | } |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | public function setName($name) { |
257 | 257 | $decoder = $this->config['decoder']['attachment']; |
258 | 258 | if ($name !== null) { |
259 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
259 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
260 | 260 | $this->name = \imap_utf8($name); |
261 | - }else{ |
|
261 | + }else { |
|
262 | 262 | $this->name = mb_decode_mimeheader($name); |
263 | 263 | } |
264 | 264 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return string|null |
271 | 271 | */ |
272 | - public function getMimeType(){ |
|
272 | + public function getMimeType() { |
|
273 | 273 | return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE); |
274 | 274 | } |
275 | 275 | |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return string|null |
280 | 280 | */ |
281 | - public function getExtension(){ |
|
281 | + public function getExtension() { |
|
282 | 282 | $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser"; |
283 | - if (class_exists($deprecated_guesser) !== false){ |
|
283 | + if (class_exists($deprecated_guesser) !== false) { |
|
284 | 284 | return $deprecated_guesser::getInstance()->guess($this->getMimeType()); |
285 | 285 | } |
286 | 286 | $guesser = "\Symfony\Component\Mime\MimeTypes"; |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return array |
295 | 295 | */ |
296 | - public function getAttributes(){ |
|
296 | + public function getAttributes() { |
|
297 | 297 | return $this->attributes; |
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
301 | 301 | * @return Message |
302 | 302 | */ |
303 | - public function getMessage(){ |
|
303 | + public function getMessage() { |
|
304 | 304 | return $this->oMessage; |
305 | 305 | } |
306 | 306 | |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return $this |
312 | 312 | */ |
313 | - public function setMask($mask){ |
|
314 | - if(class_exists($mask)){ |
|
313 | + public function setMask($mask) { |
|
314 | + if (class_exists($mask)) { |
|
315 | 315 | $this->mask = $mask; |
316 | 316 | } |
317 | 317 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @return string |
325 | 325 | */ |
326 | - public function getMask(){ |
|
326 | + public function getMask() { |
|
327 | 327 | return $this->mask; |
328 | 328 | } |
329 | 329 | |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | * @return mixed |
335 | 335 | * @throws MaskNotFoundException |
336 | 336 | */ |
337 | - public function mask($mask = null){ |
|
337 | + public function mask($mask = null) { |
|
338 | 338 | $mask = $mask !== null ? $mask : $this->mask; |
339 | - if(class_exists($mask)){ |
|
339 | + if (class_exists($mask)) { |
|
340 | 340 | return new $mask($this); |
341 | 341 | } |
342 | 342 |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | return null; |
132 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
132 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
133 | 133 | $name = Str::snake(substr($method, 3)); |
134 | 134 | |
135 | 135 | $this->attributes[$name] = array_pop($arguments); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | if (($name = $this->part->name) !== null) { |
223 | 223 | $this->setName($name); |
224 | - }elseif (($filename = $this->part->filename) !== null) { |
|
224 | + } elseif (($filename = $this->part->filename) !== null) { |
|
225 | 225 | $this->setName($filename); |
226 | 226 | } else { |
227 | 227 | $this->setName("undefined"); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | if ($name !== null) { |
259 | 259 | if($decoder === 'utf-8' && extension_loaded('imap')) { |
260 | 260 | $this->name = \imap_utf8($name); |
261 | - }else{ |
|
261 | + } else{ |
|
262 | 262 | $this->name = mb_decode_mimeheader($name); |
263 | 263 | } |
264 | 264 | } |
@@ -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\=\"?(.*)\"?/"); |
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); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
92 | 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 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | foreach($match[1] as $matched){ |
127 | 127 | $boundaries[] = str_replace('"', '', $matched); |
128 | 128 | } |
129 | - }else{ |
|
129 | + } else{ |
|
130 | 130 | if(!empty($match[1])) { |
131 | 131 | $boundaries[] = str_replace('"', '', $match[1]); |
132 | 132 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | if(strtolower(substr($method, 0, 3)) === 'get') { |
244 | 244 | $name = Str::snake(substr($method, 3)); |
245 | 245 | return $this->get($name); |
246 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
246 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
247 | 247 | $name = Str::snake(substr($method, 3)); |
248 | 248 | |
249 | 249 | if(in_array($name, array_keys($this->attributes))) { |
@@ -614,9 +614,9 @@ discard block |
||
614 | 614 | return EncodingAliases::get($parameter->value); |
615 | 615 | } |
616 | 616 | } |
617 | - }elseif (property_exists($structure, 'charset')){ |
|
617 | + } elseif (property_exists($structure, 'charset')){ |
|
618 | 618 | return EncodingAliases::get($structure->charset); |
619 | - }elseif (is_string($structure) === true){ |
|
619 | + } elseif (is_string($structure) === true){ |
|
620 | 620 | return mb_detect_encoding($structure); |
621 | 621 | } |
622 | 622 | |
@@ -660,7 +660,9 @@ discard block |
||
660 | 660 | |
661 | 661 | $this->client->openFolder($this->folder_path); |
662 | 662 | if ($this->client->getConnection()->copyMessage($folder->path, $this->msgn) == true) { |
663 | - if($expunge) $this->client->expunge(); |
|
663 | + if($expunge) { |
|
664 | + $this->client->expunge(); |
|
665 | + } |
|
664 | 666 | |
665 | 667 | $this->client->openFolder($folder->path); |
666 | 668 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -702,7 +704,9 @@ discard block |
||
702 | 704 | |
703 | 705 | $this->client->openFolder($this->folder_path); |
704 | 706 | if ($this->client->getConnection()->moveMessage($folder->path, $this->msgn) == true) { |
705 | - if($expunge) $this->client->expunge(); |
|
707 | + if($expunge) { |
|
708 | + $this->client->expunge(); |
|
709 | + } |
|
706 | 710 | |
707 | 711 | $this->client->openFolder($folder->path); |
708 | 712 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -729,7 +733,9 @@ discard block |
||
729 | 733 | */ |
730 | 734 | public function delete($expunge = true) { |
731 | 735 | $status = $this->setFlag("Deleted"); |
732 | - if($expunge) $this->client->expunge(); |
|
736 | + if($expunge) { |
|
737 | + $this->client->expunge(); |
|
738 | + } |
|
733 | 739 | |
734 | 740 | $event = $this->getEvent("message", "deleted"); |
735 | 741 | $event::dispatch($this); |
@@ -748,7 +754,9 @@ discard block |
||
748 | 754 | */ |
749 | 755 | public function restore($expunge = true) { |
750 | 756 | $status = $this->unsetFlag("Deleted"); |
751 | - if($expunge) $this->client->expunge(); |
|
757 | + if($expunge) { |
|
758 | + $this->client->expunge(); |
|
759 | + } |
|
752 | 760 | |
753 | 761 | $event = $this->getEvent("message", "restored"); |
754 | 762 | $event::dispatch($this); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | public function __construct($msgn, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false) { |
197 | 197 | |
198 | 198 | $default_mask = $client->getDefaultMessageMask(); |
199 | - if($default_mask != null) { |
|
199 | + if ($default_mask != null) { |
|
200 | 200 | $this->mask = $default_mask; |
201 | 201 | } |
202 | 202 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | * @throws MethodNotFoundException |
242 | 242 | */ |
243 | 243 | public function __call($method, $arguments) { |
244 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
244 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
245 | 245 | $name = Str::snake(substr($method, 3)); |
246 | 246 | return $this->get($name); |
247 | 247 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
248 | 248 | $name = Str::snake(substr($method, 3)); |
249 | 249 | |
250 | - if(in_array($name, array_keys($this->attributes))) { |
|
250 | + if (in_array($name, array_keys($this->attributes))) { |
|
251 | 251 | $this->attributes[$name] = array_pop($arguments); |
252 | 252 | |
253 | 253 | return $this->attributes[$name]; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @return mixed|null |
289 | 289 | */ |
290 | 290 | public function get($name) { |
291 | - if(isset($this->attributes[$name])) { |
|
291 | + if (isset($this->attributes[$name])) { |
|
292 | 292 | return $this->attributes[$name]; |
293 | 293 | } |
294 | 294 | |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | $flags = $this->client->getConnection()->flags([$this->msgn]); |
371 | 371 | |
372 | 372 | if (isset($flags[$this->msgn])) { |
373 | - foreach($flags[$this->msgn] as $flag) { |
|
374 | - if (strpos($flag, "\\") === 0){ |
|
373 | + foreach ($flags[$this->msgn] as $flag) { |
|
374 | + if (strpos($flag, "\\") === 0) { |
|
375 | 375 | $flag = substr($flag, 1); |
376 | 376 | } |
377 | 377 | $flag_key = strtolower($flag); |
@@ -435,9 +435,9 @@ discard block |
||
435 | 435 | */ |
436 | 436 | private function fetchPart(Part $part) { |
437 | 437 | |
438 | - if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])) ) ) { |
|
438 | + if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])))) { |
|
439 | 439 | |
440 | - if ( in_array(($subtype = strtolower($part->subtype)), ["plain", "csv", "html"]) && $part->filename == null && $part->name == null) { |
|
440 | + if (in_array(($subtype = strtolower($part->subtype)), ["plain", "csv", "html"]) && $part->filename == null && $part->name == null) { |
|
441 | 441 | $encoding = $this->getEncoding($part); |
442 | 442 | |
443 | 443 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -458,10 +458,10 @@ discard block |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | $this->bodies[$subtype == "plain" ? "text" : $subtype] = $content; |
461 | - } else { |
|
461 | + }else { |
|
462 | 462 | $this->fetchAttachment($part); |
463 | 463 | } |
464 | - } else { |
|
464 | + }else { |
|
465 | 465 | $this->fetchAttachment($part); |
466 | 466 | } |
467 | 467 | } |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | if ($oAttachment->getName() !== null) { |
478 | 478 | if ($oAttachment->getId() !== null) { |
479 | 479 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
480 | - } else { |
|
480 | + }else { |
|
481 | 481 | $this->attachments->push($oAttachment); |
482 | 482 | } |
483 | 483 | } |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | |
595 | 595 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
596 | 596 | return @iconv($from, $to.'//IGNORE', $str); |
597 | - } else { |
|
597 | + }else { |
|
598 | 598 | if (!$from) { |
599 | 599 | return mb_convert_encoding($str, $to); |
600 | 600 | } |
@@ -615,9 +615,9 @@ discard block |
||
615 | 615 | return EncodingAliases::get($parameter->value); |
616 | 616 | } |
617 | 617 | } |
618 | - }elseif (property_exists($structure, 'charset')){ |
|
618 | + }elseif (property_exists($structure, 'charset')) { |
|
619 | 619 | return EncodingAliases::get($structure->charset); |
620 | - }elseif (is_string($structure) === true){ |
|
620 | + }elseif (is_string($structure) === true) { |
|
621 | 621 | return mb_detect_encoding($structure); |
622 | 622 | } |
623 | 623 | |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | * @throws Exceptions\ConnectionFailedException |
632 | 632 | * @throws Exceptions\FolderFetchingException |
633 | 633 | */ |
634 | - public function getFolder(){ |
|
634 | + public function getFolder() { |
|
635 | 635 | return $this->client->getFolder($this->folder_path); |
636 | 636 | } |
637 | 637 | |
@@ -646,13 +646,13 @@ discard block |
||
646 | 646 | * @throws Exceptions\FolderFetchingException |
647 | 647 | * @throws Exceptions\GetMessagesFailedException |
648 | 648 | */ |
649 | - public function thread($sent_folder = null, &$thread = null, $folder = null){ |
|
649 | + public function thread($sent_folder = null, &$thread = null, $folder = null) { |
|
650 | 650 | $thread = $thread ? $thread : MessageCollection::make([]); |
651 | - $folder = $folder ? $folder : $this->getFolder(); |
|
651 | + $folder = $folder ? $folder : $this->getFolder(); |
|
652 | 652 | $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent")); |
653 | 653 | |
654 | 654 | /** @var Message $message */ |
655 | - foreach($thread as $message) { |
|
655 | + foreach ($thread as $message) { |
|
656 | 656 | if ($message->message_id == $this->message_id) { |
657 | 657 | return $thread; |
658 | 658 | } |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | }); |
674 | 674 | |
675 | 675 | if (is_array($this->in_reply_to)) { |
676 | - foreach($this->in_reply_to as $in_reply_to) { |
|
676 | + foreach ($this->in_reply_to as $in_reply_to) { |
|
677 | 677 | $folder->query()->messageId($in_reply_to) |
678 | 678 | ->setFetchBody($this->getFetchBodyOption()) |
679 | 679 | ->leaveUnread()->get()->each(function($message) use(&$thread, $folder, $sent_folder){ |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | |
719 | 719 | $this->client->openFolder($this->folder_path); |
720 | 720 | if ($this->client->getConnection()->copyMessage($folder->path, $this->msgn) == true) { |
721 | - if($expunge) $this->client->expunge(); |
|
721 | + if ($expunge) $this->client->expunge(); |
|
722 | 722 | |
723 | 723 | $this->client->openFolder($folder->path); |
724 | 724 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | |
761 | 761 | $this->client->openFolder($this->folder_path); |
762 | 762 | if ($this->client->getConnection()->moveMessage($folder->path, $this->msgn) == true) { |
763 | - if($expunge) $this->client->expunge(); |
|
763 | + if ($expunge) $this->client->expunge(); |
|
764 | 764 | |
765 | 765 | $this->client->openFolder($folder->path); |
766 | 766 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | */ |
788 | 788 | public function delete($expunge = true) { |
789 | 789 | $status = $this->setFlag("Deleted"); |
790 | - if($expunge) $this->client->expunge(); |
|
790 | + if ($expunge) $this->client->expunge(); |
|
791 | 791 | |
792 | 792 | $event = $this->getEvent("message", "deleted"); |
793 | 793 | $event::dispatch($this); |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | */ |
807 | 807 | public function restore($expunge = true) { |
808 | 808 | $status = $this->unsetFlag("Deleted"); |
809 | - if($expunge) $this->client->expunge(); |
|
809 | + if ($expunge) $this->client->expunge(); |
|
810 | 810 | |
811 | 811 | $event = $this->getEvent("message", "restored"); |
812 | 812 | $event::dispatch($this); |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | * |
960 | 960 | * @return object|null |
961 | 961 | */ |
962 | - public function getStructure(){ |
|
962 | + public function getStructure() { |
|
963 | 963 | return $this->structure; |
964 | 964 | } |
965 | 965 | |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | * |
986 | 986 | * @return array |
987 | 987 | */ |
988 | - public function getAttributes(){ |
|
988 | + public function getAttributes() { |
|
989 | 989 | return array_merge($this->attributes, $this->header->getAttributes()); |
990 | 990 | } |
991 | 991 | |
@@ -995,8 +995,8 @@ discard block |
||
995 | 995 | * |
996 | 996 | * @return $this |
997 | 997 | */ |
998 | - public function setMask($mask){ |
|
999 | - if(class_exists($mask)){ |
|
998 | + public function setMask($mask) { |
|
999 | + if (class_exists($mask)) { |
|
1000 | 1000 | $this->mask = $mask; |
1001 | 1001 | } |
1002 | 1002 | |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | * |
1009 | 1009 | * @return string |
1010 | 1010 | */ |
1011 | - public function getMask(){ |
|
1011 | + public function getMask() { |
|
1012 | 1012 | return $this->mask; |
1013 | 1013 | } |
1014 | 1014 | |
@@ -1019,9 +1019,9 @@ discard block |
||
1019 | 1019 | * @return mixed |
1020 | 1020 | * @throws MaskNotFoundException |
1021 | 1021 | */ |
1022 | - public function mask($mask = null){ |
|
1022 | + public function mask($mask = null) { |
|
1023 | 1023 | $mask = $mask !== null ? $mask : $this->mask; |
1024 | - if(class_exists($mask)){ |
|
1024 | + if (class_exists($mask)) { |
|
1025 | 1025 | return new $mask($this); |
1026 | 1026 | } |
1027 | 1027 |