@@ -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; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @return bool |
| 300 | 300 | */ |
| 301 | - public function isAttachment(){ |
|
| 301 | + public function isAttachment() { |
|
| 302 | 302 | if ($this->type == IMAP::MESSAGE_TYPE_TEXT && |
| 303 | 303 | ($this->ifdisposition == 0 || |
| 304 | 304 | (empty($this->disposition) || !in_array(strtolower($this->disposition), ClientManager::get('options.dispositions'))) |
@@ -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 | ) { |
@@ -80,7 +80,9 @@ discard block |
||
| 80 | 80 | $this->setClient($client); |
| 81 | 81 | |
| 82 | 82 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
| 83 | - if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 83 | + if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
| 84 | + $this->leaveUnread(); |
|
| 85 | + } |
|
| 84 | 86 | |
| 85 | 87 | if (ClientManager::get('options.fetch_order') === 'desc') { |
| 86 | 88 | $this->fetch_order = 'desc'; |
@@ -124,7 +126,9 @@ discard block |
||
| 124 | 126 | * @throws MessageSearchValidationException |
| 125 | 127 | */ |
| 126 | 128 | protected function parse_date($date) { |
| 127 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 129 | + if($date instanceof \Carbon\Carbon) { |
|
| 130 | + return $date; |
|
| 131 | + } |
|
| 128 | 132 | |
| 129 | 133 | try { |
| 130 | 134 | $date = Carbon::parse($date); |
@@ -322,7 +326,7 @@ discard block |
||
| 322 | 326 | } else { |
| 323 | 327 | if($statement[1] === null){ |
| 324 | 328 | $query .= $statement[0]; |
| 325 | - }else{ |
|
| 329 | + } else{ |
|
| 326 | 330 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 327 | 331 | } |
| 328 | 332 | } |
@@ -352,7 +356,9 @@ discard block |
||
| 352 | 356 | * @return $this |
| 353 | 357 | */ |
| 354 | 358 | public function limit($limit, $page = 1) { |
| 355 | - if($page >= 1) $this->page = $page; |
|
| 359 | + if($page >= 1) { |
|
| 360 | + $this->page = $page; |
|
| 361 | + } |
|
| 356 | 362 | $this->limit = $limit; |
| 357 | 363 | |
| 358 | 364 | return $this; |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | $this->setClient($client); |
| 81 | 81 | |
| 82 | 82 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
| 83 | - if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 83 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 84 | 84 | |
| 85 | 85 | if (ClientManager::get('options.fetch_order') === 'desc') { |
| 86 | 86 | $this->fetch_order = 'desc'; |
| 87 | - } else { |
|
| 87 | + }else { |
|
| 88 | 88 | $this->fetch_order = 'asc'; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * Instance boot method for additional functionality |
| 100 | 100 | */ |
| 101 | - protected function boot(){} |
|
| 101 | + protected function boot() {} |
|
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * Parse a given value |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | - protected function parse_value($value){ |
|
| 110 | - switch(true){ |
|
| 109 | + protected function parse_value($value) { |
|
| 110 | + switch (true) { |
|
| 111 | 111 | case $value instanceof \Carbon\Carbon: |
| 112 | 112 | $value = $value->format($this->date_format); |
| 113 | 113 | break; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @throws MessageSearchValidationException |
| 125 | 125 | */ |
| 126 | 126 | protected function parse_date($date) { |
| 127 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 127 | + if ($date instanceof \Carbon\Carbon) return $date; |
|
| 128 | 128 | |
| 129 | 129 | try { |
| 130 | 130 | $date = Carbon::parse($date); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @return Collection |
| 176 | 176 | * @throws GetMessagesFailedException |
| 177 | 177 | */ |
| 178 | - protected function search(){ |
|
| 178 | + protected function search() { |
|
| 179 | 179 | $this->generate_query(); |
| 180 | 180 | |
| 181 | 181 | try { |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | $raw_flag = isset($raw_flags[$uid]) ? $raw_flags[$uid] : []; |
| 241 | 241 | |
| 242 | 242 | $message = Message::make($uid, $msglist, $this->getClient(), $raw_header, $raw_content, $raw_flag, $this->getFetchOptions(), $this->sequence); |
| 243 | - switch ($message_key){ |
|
| 243 | + switch ($message_key) { |
|
| 244 | 244 | case 'number': |
| 245 | 245 | $key = $message->getMessageNo(); |
| 246 | 246 | break; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | return $messages; |
| 264 | 264 | } catch (\Exception $e) { |
| 265 | - throw new GetMessagesFailedException($e->getMessage(),0, $e); |
|
| 265 | + throw new GetMessagesFailedException($e->getMessage(), 0, $e); |
|
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
| 282 | 282 | * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException |
| 283 | 283 | */ |
| 284 | - public function getMessage($uid, $msglist = null, $sequence = null){ |
|
| 284 | + public function getMessage($uid, $msglist = null, $sequence = null) { |
|
| 285 | 285 | return new Message($uid, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags(), $sequence ? $sequence : $this->sequence); |
| 286 | 286 | } |
| 287 | 287 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
| 300 | 300 | * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException |
| 301 | 301 | */ |
| 302 | - public function getMessageByMsgn($msgn, $msglist = null){ |
|
| 302 | + public function getMessageByMsgn($msgn, $msglist = null) { |
|
| 303 | 303 | return $this->getMessage($msgn, $msglist, IMAP::ST_MSGN); |
| 304 | 304 | } |
| 305 | 305 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
| 317 | 317 | * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException |
| 318 | 318 | */ |
| 319 | - public function getMessageByUid($uid){ |
|
| 319 | + public function getMessageByUid($uid) { |
|
| 320 | 320 | return $this->getMessage($uid, null, IMAP::ST_UID); |
| 321 | 321 | } |
| 322 | 322 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @return LengthAwarePaginator |
| 330 | 330 | * @throws GetMessagesFailedException |
| 331 | 331 | */ |
| 332 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
| 332 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
| 333 | 333 | if ( |
| 334 | 334 | $page === null |
| 335 | 335 | && isset($_GET[$page_name]) |
@@ -355,10 +355,10 @@ discard block |
||
| 355 | 355 | $this->query->each(function($statement) use(&$query) { |
| 356 | 356 | if (count($statement) == 1) { |
| 357 | 357 | $query .= $statement[0]; |
| 358 | - } else { |
|
| 359 | - if($statement[1] === null){ |
|
| 358 | + }else { |
|
| 359 | + if ($statement[1] === null) { |
|
| 360 | 360 | $query .= $statement[0]; |
| 361 | - }else{ |
|
| 361 | + }else { |
|
| 362 | 362 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 363 | 363 | } |
| 364 | 364 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * @return $this |
| 389 | 389 | */ |
| 390 | 390 | public function limit($limit, $page = 1) { |
| 391 | - if($page >= 1) $this->page = $page; |
|
| 391 | + if ($page >= 1) $this->page = $page; |
|
| 392 | 392 | $this->limit = $limit; |
| 393 | 393 | |
| 394 | 394 | 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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return string|null |
| 103 | 103 | */ |
| 104 | - public function getBoundary(){ |
|
| 104 | + public function getBoundary() { |
|
| 105 | 105 | $boundary = $this->header->find("/boundary=\"?([^\"]*)[\";\s]/i"); |
| 106 | 106 | |
| 107 | 107 | if ($boundary === null) { |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | * @throws MessageContentFetchingException |
| 119 | 119 | * @throws InvalidMessageDateException |
| 120 | 120 | */ |
| 121 | - public function find_parts(){ |
|
| 122 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
| 123 | - if (($boundary = $this->getBoundary()) === null) { |
|
| 121 | + public function find_parts() { |
|
| 122 | + if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
| 123 | + if (($boundary = $this->getBoundary()) === null) { |
|
| 124 | 124 | throw new MessageContentFetchingException("no content found", 0); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -129,21 +129,21 @@ discard block |
||
| 129 | 129 | ]; |
| 130 | 130 | |
| 131 | 131 | if (preg_match("/boundary\=\"?(.*)\"?/", $this->raw, $match) == 1) { |
| 132 | - if(is_array($match[1])){ |
|
| 133 | - foreach($match[1] as $matched){ |
|
| 132 | + if (is_array($match[1])) { |
|
| 133 | + foreach ($match[1] as $matched) { |
|
| 134 | 134 | $boundaries[] = str_replace('"', '', $matched); |
| 135 | 135 | } |
| 136 | - }else{ |
|
| 137 | - if(!empty($match[1])) { |
|
| 136 | + }else { |
|
| 137 | + if (!empty($match[1])) { |
|
| 138 | 138 | $boundaries[] = str_replace('"', '', $match[1]); |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $raw_parts = explode( $boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw) ); |
|
| 143 | + $raw_parts = explode($boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw)); |
|
| 144 | 144 | $parts = []; |
| 145 | 145 | $part_number = 0; |
| 146 | - foreach($raw_parts as $part) { |
|
| 146 | + foreach ($raw_parts as $part) { |
|
| 147 | 147 | $part = trim(rtrim($part)); |
| 148 | 148 | if ($part !== "--") { |
| 149 | 149 | $parts[] = new Part($part, null, $part_number); |
@@ -377,7 +377,7 @@ |
||
| 377 | 377 | if (strpos($folder_name, $delimiter) !== false) { |
| 378 | 378 | return $this->getFolderByPath($folder_name); |
| 379 | 379 | } |
| 380 | - } |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | 382 | return $this->getFolderByName($folder_name); |
| 383 | 383 | } |
@@ -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; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $value = $this->default_account_config[$key]; |
| 199 | 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; |
@@ -232,39 +232,39 @@ discard block |
||
| 232 | 232 | if(isset($config['masks']['message'])) { |
| 233 | 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{ |
|
| 238 | + } else{ |
|
| 239 | 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 | 245 | if(isset($config['masks']['attachment'])) { |
| 246 | 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{ |
|
| 251 | + } else{ |
|
| 252 | 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{ |
|
| 258 | + } else{ |
|
| 259 | 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 | 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 | } |
@@ -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,7 +493,9 @@ discard block |
||
| 493 | 493 | $this->checkConnection(); |
| 494 | 494 | $status = $this->connection->createFolder($folder); |
| 495 | 495 | |
| 496 | - if($expunge) $this->expunge(); |
|
| 496 | + if($expunge) { |
|
| 497 | + $this->expunge(); |
|
| 498 | + } |
|
| 497 | 499 | |
| 498 | 500 | $folder = $this->getFolder($folder); |
| 499 | 501 | if($status && $folder) { |
@@ -232,7 +232,9 @@ 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) { |
|
| 236 | + $this->client->expunge(); |
|
| 237 | + } |
|
| 236 | 238 | |
| 237 | 239 | $folder = $this->client->getFolder($new_name); |
| 238 | 240 | $event = $this->getEvent("folder", "moved"); |
@@ -306,7 +308,9 @@ discard block |
||
| 306 | 308 | */ |
| 307 | 309 | public function delete($expunge = true) { |
| 308 | 310 | $status = $this->client->getConnection()->deleteFolder($this->path); |
| 309 | - if($expunge) $this->client->expunge(); |
|
| 311 | + if($expunge) { |
|
| 312 | + $this->client->expunge(); |
|
| 313 | + } |
|
| 310 | 314 | |
| 311 | 315 | $event = $this->getEvent("folder", "deleted"); |
| 312 | 316 | $event::dispatch($this); |
@@ -374,7 +378,7 @@ discard block |
||
| 374 | 378 | |
| 375 | 379 | $connection->idle(); |
| 376 | 380 | } |
| 377 | - }catch (Exceptions\RuntimeException $e) { |
|
| 381 | + } catch (Exceptions\RuntimeException $e) { |
|
| 378 | 382 | if(strpos($e->getMessage(), "connection closed") === false) { |
| 379 | 383 | throw $e; |
| 380 | 384 | } |
@@ -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); |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | try { |
| 371 | 371 | $line = $connection->nextLine(); |
| 372 | 372 | if (($pos = strpos($line, "EXISTS")) !== false) { |
| 373 | - $msgn = (int) substr($line, 2, $pos -2); |
|
| 373 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
| 374 | 374 | $connection->done(); |
| 375 | 375 | |
| 376 | 376 | $this->client->openFolder($this->path, true); |
@@ -383,8 +383,8 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | $connection->idle(); |
| 385 | 385 | } |
| 386 | - }catch (Exceptions\RuntimeException $e) { |
|
| 387 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
| 386 | + } catch (Exceptions\RuntimeException $e) { |
|
| 387 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
| 388 | 388 | throw $e; |
| 389 | 389 | } |
| 390 | 390 | } |
@@ -426,8 +426,8 @@ discard block |
||
| 426 | 426 | * Set the delimiter |
| 427 | 427 | * @param $delimiter |
| 428 | 428 | */ |
| 429 | - public function setDelimiter($delimiter){ |
|
| 430 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
| 429 | + public function setDelimiter($delimiter) { |
|
| 430 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
| 431 | 431 | $delimiter = ClientManager::get('options.delimiter', '/'); |
| 432 | 432 | } |
| 433 | 433 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | throw new AuthFailedException($message); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if(!$this->stream) { |
|
| 90 | + if (!$this->stream) { |
|
| 91 | 91 | $errors = \imap_errors(); |
| 92 | 92 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
| 93 | 93 | throw new AuthFailedException($message); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | if (!$this->cert_validation) { |
| 119 | 119 | $address .= '/novalidate-cert'; |
| 120 | 120 | } |
| 121 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
| 121 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
| 122 | 122 | $address .= '/'.$this->encryption; |
| 123 | 123 | } elseif ($this->encryption === "starttls") { |
| 124 | 124 | $address .= '/tls'; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @return bool |
| 148 | 148 | */ |
| 149 | - public function connected(){ |
|
| 149 | + public function connected() { |
|
| 150 | 150 | return !$this->stream; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @return array |
| 220 | 220 | */ |
| 221 | - public function headers($uids, $rfc = "RFC822", $uid = false){ |
|
| 221 | + public function headers($uids, $rfc = "RFC822", $uid = false) { |
|
| 222 | 222 | $result = []; |
| 223 | 223 | $uids = is_array($uids) ? $uids : [$uids]; |
| 224 | 224 | foreach ($uids as $uid) { |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * |
| 235 | 235 | * @return array |
| 236 | 236 | */ |
| 237 | - public function flags($uids, $uid = false){ |
|
| 237 | + public function flags($uids, $uid = false) { |
|
| 238 | 238 | $result = []; |
| 239 | 239 | $uids = is_array($uids) ? $uids : [$uids]; |
| 240 | 240 | foreach ($uids as $uid) { |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | $flags = []; |
| 243 | 243 | if (is_array($raw_flags) && isset($raw_flags[0])) { |
| 244 | 244 | $raw_flags = (array) $raw_flags[0]; |
| 245 | - foreach($raw_flags as $flag => $value) { |
|
| 246 | - if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){ |
|
| 245 | + foreach ($raw_flags as $flag => $value) { |
|
| 246 | + if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) { |
|
| 247 | 247 | $flags[] = "\\".ucfirst($flag); |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | if ($id === null) { |
| 265 | 265 | $overview = $this->overview("1:*"); |
| 266 | 266 | $uids = []; |
| 267 | - foreach($overview as $set){ |
|
| 267 | + foreach ($overview as $set) { |
|
| 268 | 268 | $uids[$set->msgno] = $set->uid; |
| 269 | 269 | } |
| 270 | 270 | return $uids; |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @return array |
| 291 | 291 | */ |
| 292 | 292 | public function overview($sequence, $uid = false) { |
| 293 | - return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::FT_UID : IMAP::NIL); |
|
| 293 | + return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::FT_UID : IMAP::NIL); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | $result = []; |
| 306 | 306 | |
| 307 | 307 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
| 308 | - if(is_array($items)){ |
|
| 308 | + if (is_array($items)) { |
|
| 309 | 309 | foreach ($items as $item) { |
| 310 | 310 | $name = $this->decodeFolderName($item->name); |
| 311 | 311 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
| 312 | 312 | } |
| 313 | - }else{ |
|
| 313 | + }else { |
|
| 314 | 314 | throw new RuntimeException(\imap_last_error()); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -332,9 +332,9 @@ discard block |
||
| 332 | 332 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) { |
| 333 | 333 | $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags); |
| 334 | 334 | |
| 335 | - if ($mode == "+"){ |
|
| 335 | + if ($mode == "+") { |
|
| 336 | 336 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
| 337 | - }else{ |
|
| 337 | + }else { |
|
| 338 | 338 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
| 339 | 339 | } |
| 340 | 340 | |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 357 | public function appendMessage($folder, $message, $flags = null, $date = null) { |
| 358 | 358 | if ($date != null) { |
| 359 | - if ($date instanceof \Carbon\Carbon){ |
|
| 359 | + if ($date instanceof \Carbon\Carbon) { |
|
| 360 | 360 | $date = $date->format('d-M-Y H:i:s O'); |
| 361 | 361 | } |
| 362 | 362 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -493,14 +493,14 @@ discard block |
||
| 493 | 493 | /** |
| 494 | 494 | * Enable the debug mode |
| 495 | 495 | */ |
| 496 | - public function enableDebug(){ |
|
| 496 | + public function enableDebug() { |
|
| 497 | 497 | $this->debug = true; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
| 501 | 501 | * Disable the debug mode |
| 502 | 502 | */ |
| 503 | - public function disableDebug(){ |
|
| 503 | + public function disableDebug() { |
|
| 504 | 504 | $this->debug = false; |
| 505 | 505 | } |
| 506 | 506 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | $name = $this->decodeFolderName($item->name); |
| 311 | 311 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
| 312 | 312 | } |
| 313 | - }else{ |
|
| 313 | + } else{ |
|
| 314 | 314 | throw new RuntimeException(\imap_last_error()); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | if ($mode == "+"){ |
| 336 | 336 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
| 337 | - }else{ |
|
| 337 | + } else{ |
|
| 338 | 338 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
| 339 | 339 | } |
| 340 | 340 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | public function add($value, $strict = false) { |
| 75 | 75 | if (is_array($value)) { |
| 76 | 76 | return $this->merge($value, $strict); |
| 77 | - }elseif ($value !== null) { |
|
| 77 | + } elseif ($value !== null) { |
|
| 78 | 78 | $this->attach($value, $strict); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | if ($this->contains($value) === false) { |
| 124 | 124 | $this->values[] = $value; |
| 125 | 125 | } |
| 126 | - }else{ |
|
| 126 | + } else{ |
|
| 127 | 127 | $this->values[] = $value; |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - public function toString(){ |
|
| 63 | + public function toString() { |
|
| 64 | 64 | return $this->__toString(); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return array |
| 71 | 71 | */ |
| 72 | - public function __serialize(){ |
|
| 72 | + public function __serialize() { |
|
| 73 | 73 | return $this->values; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return array |
| 80 | 80 | */ |
| 81 | - public function toArray(){ |
|
| 81 | + public function toArray() { |
|
| 82 | 82 | return $this->__serialize(); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | if ($this->contains($value) === false) { |
| 142 | 142 | $this->values[] = $value; |
| 143 | 143 | } |
| 144 | - }else{ |
|
| 144 | + }else { |
|
| 145 | 145 | $this->values[] = $value; |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return Attribute |
| 154 | 154 | */ |
| 155 | - public function setName($name){ |
|
| 155 | + public function setName($name) { |
|
| 156 | 156 | $this->name = $name; |
| 157 | 157 | |
| 158 | 158 | return $this; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return string |
| 165 | 165 | */ |
| 166 | - public function getName(){ |
|
| 166 | + public function getName() { |
|
| 167 | 167 | return $this->name; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return array |
| 174 | 174 | */ |
| 175 | - public function get(){ |
|
| 175 | + public function get() { |
|
| 176 | 176 | return $this->values; |
| 177 | 177 | } |
| 178 | 178 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | * @return array |
| 183 | 183 | */ |
| 184 | - public function all(){ |
|
| 184 | + public function all() { |
|
| 185 | 185 | return $this->get(); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return mixed|null |
| 192 | 192 | */ |
| 193 | - public function first(){ |
|
| 193 | + public function first() { |
|
| 194 | 194 | if (count($this->values) > 0) { |
| 195 | 195 | return $this->values[0]; |
| 196 | 196 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * |
| 203 | 203 | * @return mixed|null |
| 204 | 204 | */ |
| 205 | - public function last(){ |
|
| 205 | + public function last() { |
|
| 206 | 206 | $cnt = count($this->values); |
| 207 | 207 | if ($cnt > 0) { |
| 208 | 208 | return $this->values[$cnt - 1]; |