@@ -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) { |