@@ -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); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @throws Exceptions\ConnectionFailedException |
140 | 140 | * @throws Exceptions\RuntimeException |
141 | 141 | */ |
142 | - public function query($charset = 'UTF-8'){ |
|
142 | + public function query($charset = 'UTF-8') { |
|
143 | 143 | $this->getClient()->checkConnection(); |
144 | 144 | $this->getClient()->openFolder($this->path); |
145 | 145 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @throws Exceptions\ConnectionFailedException |
152 | 152 | * @throws Exceptions\RuntimeException |
153 | 153 | */ |
154 | - public function search($charset = 'UTF-8'){ |
|
154 | + public function search($charset = 'UTF-8') { |
|
155 | 155 | return $this->query($charset); |
156 | 156 | } |
157 | 157 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @throws Exceptions\ConnectionFailedException |
161 | 161 | * @throws Exceptions\RuntimeException |
162 | 162 | */ |
163 | - public function messages($charset = 'UTF-8'){ |
|
163 | + public function messages($charset = 'UTF-8') { |
|
164 | 164 | return $this->query($charset); |
165 | 165 | } |
166 | 166 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | public function move($new_name, $expunge = true) { |
236 | 236 | $this->client->checkConnection(); |
237 | 237 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
238 | - if($expunge) $this->client->expunge(); |
|
238 | + if ($expunge) $this->client->expunge(); |
|
239 | 239 | |
240 | 240 | $folder = $this->client->getFolder($new_name); |
241 | 241 | $event = $this->getEvent("folder", "moved"); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @throws ConnectionFailedException |
253 | 253 | * @throws Exceptions\RuntimeException |
254 | 254 | */ |
255 | - public function overview($sequence = null){ |
|
255 | + public function overview($sequence = null) { |
|
256 | 256 | $this->client->openFolder($this->path); |
257 | 257 | $sequence = $sequence === null ? "1:*" : $sequence; |
258 | 258 | $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | |
279 | 279 | if ($internal_date != null) { |
280 | - if ($internal_date instanceof Carbon){ |
|
280 | + if ($internal_date instanceof Carbon) { |
|
281 | 281 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
282 | 282 | } |
283 | 283 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function delete($expunge = true) { |
313 | 313 | $status = $this->client->getConnection()->deleteFolder($this->path); |
314 | - if($expunge) $this->client->expunge(); |
|
314 | + if ($expunge) $this->client->expunge(); |
|
315 | 315 | |
316 | 316 | $event = $this->getEvent("folder", "deleted"); |
317 | 317 | $event::dispatch($this); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $line = $connection->nextLine(); |
373 | 373 | if (($pos = strpos($line, "EXISTS")) !== false) { |
374 | - $msgn = (int) substr($line, 2, $pos -2); |
|
374 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
375 | 375 | $connection->done(); |
376 | 376 | |
377 | 377 | $this->client->openFolder($this->path, true); |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | |
385 | 385 | $connection->idle(); |
386 | 386 | } |
387 | - }catch (Exceptions\RuntimeException $e) { |
|
388 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
387 | + } catch (Exceptions\RuntimeException $e) { |
|
388 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
389 | 389 | throw $e; |
390 | 390 | } |
391 | 391 | if ($auto_reconnect === true) { |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | * Set the delimiter |
431 | 431 | * @param $delimiter |
432 | 432 | */ |
433 | - public function setDelimiter($delimiter){ |
|
434 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
433 | + public function setDelimiter($delimiter) { |
|
434 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
435 | 435 | $delimiter = ClientManager::get('options.delimiter', '/'); |
436 | 436 | } |
437 | 437 |
@@ -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; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return bool |
300 | 300 | */ |
301 | - public function isAttachment(){ |
|
301 | + public function isAttachment() { |
|
302 | 302 | $valid_disposition = in_array(strtolower($this->disposition), ClientManager::get('options.dispositions')); |
303 | 303 | if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition))) && !$valid_disposition) { |
304 | 304 | if (($this->subtype == null || in_array((strtolower($this->subtype)), ["plain", "csv", "html"])) && $this->filename == null && $this->name == null) { |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | * @param array $config |
202 | 202 | * @param array $default_config |
203 | 203 | */ |
204 | - private function setAccountConfig($key, $config, $default_config){ |
|
204 | + private function setAccountConfig($key, $config, $default_config) { |
|
205 | 205 | $value = $this->default_account_config[$key]; |
206 | - if(isset($config[$key])) { |
|
206 | + if (isset($config[$key])) { |
|
207 | 207 | $value = $config[$key]; |
208 | - }elseif(isset($default_config[$key])) { |
|
208 | + }elseif (isset($default_config[$key])) { |
|
209 | 209 | $value = $default_config[$key]; |
210 | 210 | } |
211 | 211 | $this->$key = $value; |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function setEventsFromConfig($config) { |
219 | 219 | $this->events = ClientManager::get("events"); |
220 | - if(isset($config['events'])){ |
|
221 | - if(isset($config['events'])) { |
|
222 | - foreach($config['events'] as $section => $events) { |
|
220 | + if (isset($config['events'])) { |
|
221 | + if (isset($config['events'])) { |
|
222 | + foreach ($config['events'] as $section => $events) { |
|
223 | 223 | $this->events[$section] = array_merge($this->events[$section], $events); |
224 | 224 | } |
225 | 225 | } |
@@ -233,45 +233,45 @@ discard block |
||
233 | 233 | * @throws MaskNotFoundException |
234 | 234 | */ |
235 | 235 | protected function setMaskFromConfig($config) { |
236 | - $default_config = ClientManager::get("masks"); |
|
236 | + $default_config = ClientManager::get("masks"); |
|
237 | 237 | |
238 | - if(isset($config['masks'])){ |
|
239 | - if(isset($config['masks']['message'])) { |
|
240 | - if(class_exists($config['masks']['message'])) { |
|
238 | + if (isset($config['masks'])) { |
|
239 | + if (isset($config['masks']['message'])) { |
|
240 | + if (class_exists($config['masks']['message'])) { |
|
241 | 241 | $this->default_message_mask = $config['masks']['message']; |
242 | - }else{ |
|
242 | + }else { |
|
243 | 243 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
244 | 244 | } |
245 | - }else{ |
|
246 | - if(class_exists($default_config['message'])) { |
|
245 | + }else { |
|
246 | + if (class_exists($default_config['message'])) { |
|
247 | 247 | $this->default_message_mask = $default_config['message']; |
248 | - }else{ |
|
248 | + }else { |
|
249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
250 | 250 | } |
251 | 251 | } |
252 | - if(isset($config['masks']['attachment'])) { |
|
253 | - if(class_exists($config['masks']['attachment'])) { |
|
252 | + if (isset($config['masks']['attachment'])) { |
|
253 | + if (class_exists($config['masks']['attachment'])) { |
|
254 | 254 | $this->default_message_mask = $config['masks']['attachment']; |
255 | - }else{ |
|
255 | + }else { |
|
256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
257 | 257 | } |
258 | - }else{ |
|
259 | - if(class_exists($default_config['attachment'])) { |
|
258 | + }else { |
|
259 | + if (class_exists($default_config['attachment'])) { |
|
260 | 260 | $this->default_message_mask = $default_config['attachment']; |
261 | - }else{ |
|
261 | + }else { |
|
262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
263 | 263 | } |
264 | 264 | } |
265 | - }else{ |
|
266 | - if(class_exists($default_config['message'])) { |
|
265 | + }else { |
|
266 | + if (class_exists($default_config['message'])) { |
|
267 | 267 | $this->default_message_mask = $default_config['message']; |
268 | - }else{ |
|
268 | + }else { |
|
269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
270 | 270 | } |
271 | 271 | |
272 | - if(class_exists($default_config['attachment'])) { |
|
272 | + if (class_exists($default_config['attachment'])) { |
|
273 | 273 | $this->default_message_mask = $default_config['attachment']; |
274 | - }else{ |
|
274 | + }else { |
|
275 | 275 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
276 | 276 | } |
277 | 277 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
336 | 336 | $this->connection->setConnectionTimeout($this->timeout); |
337 | 337 | $this->connection->setProxy($this->proxy); |
338 | - }else{ |
|
338 | + }else { |
|
339 | 339 | if (extension_loaded('imap') === false) { |
340 | 340 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
341 | 341 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
459 | 459 | $items = $this->connection->folders('', $pattern); |
460 | 460 | |
461 | - if(is_array($items)){ |
|
461 | + if (is_array($items)) { |
|
462 | 462 | foreach ($items as $folder_name => $item) { |
463 | 463 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
464 | 464 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } |
474 | 474 | |
475 | 475 | return $folders; |
476 | - }else{ |
|
476 | + }else { |
|
477 | 477 | throw new FolderFetchingException("failed to fetch any folders"); |
478 | 478 | } |
479 | 479 | } |
@@ -511,10 +511,10 @@ discard block |
||
511 | 511 | $this->checkConnection(); |
512 | 512 | $status = $this->connection->createFolder($folder); |
513 | 513 | |
514 | - if($expunge) $this->expunge(); |
|
514 | + if ($expunge) $this->expunge(); |
|
515 | 515 | |
516 | 516 | $folder = $this->getFolder($folder); |
517 | - if($status && $folder) { |
|
517 | + if ($status && $folder) { |
|
518 | 518 | $event = $this->getEvent("folder", "new"); |
519 | 519 | $event::dispatch($folder); |
520 | 520 | } |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return Folder |
542 | 542 | */ |
543 | - public function getFolderPath(){ |
|
543 | + public function getFolderPath() { |
|
544 | 544 | return $this->active_folder; |
545 | 545 | } |
546 | 546 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @return int |
598 | 598 | */ |
599 | - public function getTimeout($type){ |
|
599 | + public function getTimeout($type) { |
|
600 | 600 | return $this->connection->getConnectionTimeout(); |
601 | 601 | } |
602 | 602 | |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | * |
606 | 606 | * @return string |
607 | 607 | */ |
608 | - public function getDefaultMessageMask(){ |
|
608 | + public function getDefaultMessageMask() { |
|
609 | 609 | return $this->default_message_mask; |
610 | 610 | } |
611 | 611 | |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @return array |
617 | 617 | */ |
618 | - public function getDefaultEvents($section){ |
|
618 | + public function getDefaultEvents($section) { |
|
619 | 619 | return $this->events[$section]; |
620 | 620 | } |
621 | 621 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @throws MaskNotFoundException |
628 | 628 | */ |
629 | 629 | public function setDefaultMessageMask($mask) { |
630 | - if(class_exists($mask)) { |
|
630 | + if (class_exists($mask)) { |
|
631 | 631 | $this->default_message_mask = $mask; |
632 | 632 | |
633 | 633 | return $this; |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | * |
642 | 642 | * @return string |
643 | 643 | */ |
644 | - public function getDefaultAttachmentMask(){ |
|
644 | + public function getDefaultAttachmentMask() { |
|
645 | 645 | return $this->default_attachment_mask; |
646 | 646 | } |
647 | 647 | |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * @throws MaskNotFoundException |
654 | 654 | */ |
655 | 655 | public function setDefaultAttachmentMask($mask) { |
656 | - if(class_exists($mask)) { |
|
656 | + if (class_exists($mask)) { |
|
657 | 657 | $this->default_attachment_mask = $mask; |
658 | 658 | |
659 | 659 | return $this; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $value = $this->default_account_config[$key]; |
206 | 206 | if(isset($config[$key])) { |
207 | 207 | $value = $config[$key]; |
208 | - }elseif(isset($default_config[$key])) { |
|
208 | + } elseif(isset($default_config[$key])) { |
|
209 | 209 | $value = $default_config[$key]; |
210 | 210 | } |
211 | 211 | $this->$key = $value; |
@@ -239,39 +239,39 @@ discard block |
||
239 | 239 | if(isset($config['masks']['message'])) { |
240 | 240 | if(class_exists($config['masks']['message'])) { |
241 | 241 | $this->default_message_mask = $config['masks']['message']; |
242 | - }else{ |
|
242 | + } else{ |
|
243 | 243 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
244 | 244 | } |
245 | - }else{ |
|
245 | + } else{ |
|
246 | 246 | if(class_exists($default_config['message'])) { |
247 | 247 | $this->default_message_mask = $default_config['message']; |
248 | - }else{ |
|
248 | + } else{ |
|
249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
250 | 250 | } |
251 | 251 | } |
252 | 252 | if(isset($config['masks']['attachment'])) { |
253 | 253 | if(class_exists($config['masks']['attachment'])) { |
254 | 254 | $this->default_message_mask = $config['masks']['attachment']; |
255 | - }else{ |
|
255 | + } else{ |
|
256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
257 | 257 | } |
258 | - }else{ |
|
258 | + } else{ |
|
259 | 259 | if(class_exists($default_config['attachment'])) { |
260 | 260 | $this->default_message_mask = $default_config['attachment']; |
261 | - }else{ |
|
261 | + } else{ |
|
262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
263 | 263 | } |
264 | 264 | } |
265 | - }else{ |
|
265 | + } else{ |
|
266 | 266 | if(class_exists($default_config['message'])) { |
267 | 267 | $this->default_message_mask = $default_config['message']; |
268 | - }else{ |
|
268 | + } else{ |
|
269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
270 | 270 | } |
271 | 271 | |
272 | 272 | if(class_exists($default_config['attachment'])) { |
273 | 273 | $this->default_message_mask = $default_config['attachment']; |
274 | - }else{ |
|
274 | + } else{ |
|
275 | 275 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
276 | 276 | } |
277 | 277 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
336 | 336 | $this->connection->setConnectionTimeout($this->timeout); |
337 | 337 | $this->connection->setProxy($this->proxy); |
338 | - }else{ |
|
338 | + } else{ |
|
339 | 339 | if (extension_loaded('imap') === false) { |
340 | 340 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
341 | 341 | } |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } |
474 | 474 | |
475 | 475 | return $folders; |
476 | - }else{ |
|
476 | + } else{ |
|
477 | 477 | throw new FolderFetchingException("failed to fetch any folders"); |
478 | 478 | } |
479 | 479 | } |
@@ -511,7 +511,9 @@ discard block |
||
511 | 511 | $this->checkConnection(); |
512 | 512 | $status = $this->connection->createFolder($folder); |
513 | 513 | |
514 | - if($expunge) $this->expunge(); |
|
514 | + if($expunge) { |
|
515 | + $this->expunge(); |
|
516 | + } |
|
515 | 517 | |
516 | 518 | $folder = $this->getFolder($folder); |
517 | 519 | if($status && $folder) { |