@@ -338,13 +338,13 @@ |
||
| 338 | 338 | return imap_renamemailbox($this->connection, $this->getAddress() . imap_utf7_encode($old_name), $this->getAddress() . imap_utf7_encode($new_name)); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - /** |
|
| 342 | - * Delete Folder |
|
| 343 | - * @param string $name |
|
| 344 | - * |
|
| 345 | - * @return bool |
|
| 346 | - * @throws ConnectionFailedException |
|
| 347 | - */ |
|
| 341 | + /** |
|
| 342 | + * Delete Folder |
|
| 343 | + * @param string $name |
|
| 344 | + * |
|
| 345 | + * @return bool |
|
| 346 | + * @throws ConnectionFailedException |
|
| 347 | + */ |
|
| 348 | 348 | public function deleteFolder($name) { |
| 349 | 349 | $this->checkConnection(); |
| 350 | 350 | return imap_deletemailbox($this->connection, $this->getAddress() . imap_utf7_encode($name)); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @var array $validConfigKeys |
| 115 | 115 | */ |
| 116 | - protected $validConfigKeys = ['host', 'port', 'encryption', 'validate_cert', 'username', 'password','protocol']; |
|
| 116 | + protected $validConfigKeys = ['host', 'port', 'encryption', 'validate_cert', 'username', 'password', 'protocol']; |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * Client constructor. |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | public function createFolder($name) { |
| 332 | 332 | $this->checkConnection(); |
| 333 | - return imap_createmailbox($this->connection, $this->getAddress() . imap_utf7_encode($name)); |
|
| 333 | + return imap_createmailbox($this->connection, $this->getAddress().imap_utf7_encode($name)); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | /** |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | public function renameFolder($old_name, $new_name) { |
| 345 | 345 | $this->checkConnection(); |
| 346 | - return imap_renamemailbox($this->connection, $this->getAddress() . imap_utf7_encode($old_name), $this->getAddress() . imap_utf7_encode($new_name)); |
|
| 346 | + return imap_renamemailbox($this->connection, $this->getAddress().imap_utf7_encode($old_name), $this->getAddress().imap_utf7_encode($new_name)); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | */ |
| 356 | 356 | public function deleteFolder($name) { |
| 357 | 357 | $this->checkConnection(); |
| 358 | - return imap_deletemailbox($this->connection, $this->getAddress() . imap_utf7_encode($name)); |
|
| 358 | + return imap_deletemailbox($this->connection, $this->getAddress().imap_utf7_encode($name)); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
@@ -238,14 +238,14 @@ |
||
| 238 | 238 | /** |
| 239 | 239 | * @return string|null |
| 240 | 240 | */ |
| 241 | - public function getMimeType(){ |
|
| 241 | + public function getMimeType() { |
|
| 242 | 242 | return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
| 246 | 246 | * @return string|null |
| 247 | 247 | */ |
| 248 | - public function getExtension(){ |
|
| 248 | + public function getExtension() { |
|
| 249 | 249 | return ExtensionGuesser::getInstance()->guess($this->getMimeType()); |
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | \ No newline at end of file |
@@ -432,12 +432,12 @@ |
||
| 432 | 432 | public function parseBody() { |
| 433 | 433 | $structure = imap_fetchstructure($this->client->getConnection(), $this->uid, $this->fetch_options); |
| 434 | 434 | |
| 435 | - if(property_exists($structure, 'parts')){ |
|
| 435 | + if (property_exists($structure, 'parts')) { |
|
| 436 | 436 | $parts = $structure->parts; |
| 437 | 437 | |
| 438 | - foreach ($parts as $part) { |
|
| 439 | - foreach ($part->parameters as $parameter) { |
|
| 440 | - if($parameter->attribute == "charset") { |
|
| 438 | + foreach ($parts as $part) { |
|
| 439 | + foreach ($part->parameters as $parameter) { |
|
| 440 | + if ($parameter->attribute == "charset") { |
|
| 441 | 441 | $encoding = $parameter->value; |
| 442 | 442 | $parameter->value = preg_replace('/Content-Transfer-Encoding/', '', $encoding); |
| 443 | 443 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @return WhereQuery |
| 132 | 132 | */ |
| 133 | - public function query($charset = 'UTF-8'){ |
|
| 133 | + public function query($charset = 'UTF-8') { |
|
| 134 | 134 | $this->getClient()->checkConnection(); |
| 135 | 135 | $this->getClient()->openFolder($this); |
| 136 | 136 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * @deprecated 1.2.1:2.0.0 No longer needed. Use Folder::query() instead |
| 295 | 295 | * @see Folder::query() |
| 296 | 296 | */ |
| 297 | - public function searchMessages(array $where, $fetch_options = null, $fetch_body = true, $fetch_attachment = true, $fetch_flags = false, $limit = null, $page = 1, $charset = "UTF-8") { |
|
| 297 | + public function searchMessages(array $where, $fetch_options = null, $fetch_body = true, $fetch_attachment = true, $fetch_flags = false, $limit = null, $page = 1, $charset = "UTF-8") { |
|
| 298 | 298 | $this->getClient()->checkConnection(); |
| 299 | 299 | |
| 300 | 300 | return $this->query($charset)->where($where)->setFetchOptions($fetch_options)->setFetchBody($fetch_body) |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function __call($name, $arguments) { |
| 44 | 44 | $method = 'where'.ucfirst($name); |
| 45 | - if(method_exists($this, $method) === true){ |
|
| 45 | + if (method_exists($this, $method) === true) { |
|
| 46 | 46 | return call_user_func_array([$this, $method], $arguments); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | protected function validate_criteria($criteria) { |
| 60 | 60 | $criteria = strtoupper($criteria); |
| 61 | 61 | |
| 62 | - if(in_array($criteria, $this->available_criteria) === false) { |
|
| 62 | + if (in_array($criteria, $this->available_criteria) === false) { |
|
| 63 | 63 | throw new InvalidWhereQueryCriteriaException(); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -73,21 +73,21 @@ discard block |
||
| 73 | 73 | * @return $this |
| 74 | 74 | */ |
| 75 | 75 | public function where($criteria, $value = null) { |
| 76 | - if(is_array($criteria)){ |
|
| 77 | - foreach($criteria as $arguments){ |
|
| 78 | - if(count($arguments) == 1){ |
|
| 76 | + if (is_array($criteria)) { |
|
| 77 | + foreach ($criteria as $arguments) { |
|
| 78 | + if (count($arguments) == 1) { |
|
| 79 | 79 | $this->where($arguments[0]); |
| 80 | - }elseif(count($arguments) == 2){ |
|
| 80 | + }elseif (count($arguments) == 2) { |
|
| 81 | 81 | $this->where($arguments[0], $arguments[1]); |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | - }else{ |
|
| 84 | + } else { |
|
| 85 | 85 | $criteria = $this->validate_criteria($criteria); |
| 86 | 86 | $value = $this->parse_value($value); |
| 87 | 87 | |
| 88 | - if($value === null || $value === ''){ |
|
| 88 | + if ($value === null || $value === '') { |
|
| 89 | 89 | $this->query->push([$criteria]); |
| 90 | - }else{ |
|
| 90 | + } else { |
|
| 91 | 91 | $this->query->push([$criteria, $value]); |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function orWhere(\Closure $closure = null) { |
| 104 | 104 | $this->query->push(['OR']); |
| 105 | - if($closure !== null) $closure($this); |
|
| 105 | + if ($closure !== null) $closure($this); |
|
| 106 | 106 | |
| 107 | 107 | return $this; |
| 108 | 108 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function andWhere(\Closure $closure = null) { |
| 116 | 116 | $this->query->push(['AND']); |
| 117 | - if($closure !== null) $closure($this); |
|
| 117 | + if ($closure !== null) $closure($this); |
|
| 118 | 118 | |
| 119 | 119 | return $this; |
| 120 | 120 | } |
@@ -77,17 +77,17 @@ discard block |
||
| 77 | 77 | foreach($criteria as $arguments){ |
| 78 | 78 | if(count($arguments) == 1){ |
| 79 | 79 | $this->where($arguments[0]); |
| 80 | - }elseif(count($arguments) == 2){ |
|
| 80 | + } elseif(count($arguments) == 2){ |
|
| 81 | 81 | $this->where($arguments[0], $arguments[1]); |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | - }else{ |
|
| 84 | + } else{ |
|
| 85 | 85 | $criteria = $this->validate_criteria($criteria); |
| 86 | 86 | $value = $this->parse_value($value); |
| 87 | 87 | |
| 88 | 88 | if($value === null || $value === ''){ |
| 89 | 89 | $this->query->push([$criteria]); |
| 90 | - }else{ |
|
| 90 | + } else{ |
|
| 91 | 91 | $this->query->push([$criteria, $value]); |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -102,7 +102,9 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function orWhere(\Closure $closure = null) { |
| 104 | 104 | $this->query->push(['OR']); |
| 105 | - if($closure !== null) $closure($this); |
|
| 105 | + if($closure !== null) { |
|
| 106 | + $closure($this); |
|
| 107 | + } |
|
| 106 | 108 | |
| 107 | 109 | return $this; |
| 108 | 110 | } |
@@ -114,7 +116,9 @@ discard block |
||
| 114 | 116 | */ |
| 115 | 117 | public function andWhere(\Closure $closure = null) { |
| 116 | 118 | $this->query->push(['AND']); |
| 117 | - if($closure !== null) $closure($this); |
|
| 119 | + if($closure !== null) { |
|
| 120 | + $closure($this); |
|
| 121 | + } |
|
| 118 | 122 | |
| 119 | 123 | return $this; |
| 120 | 124 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | /** |
| 72 | 72 | * Instance boot method for additional functionality |
| 73 | 73 | */ |
| 74 | - protected function boot(){} |
|
| 74 | + protected function boot() {} |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Parse a given value |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | - protected function parse_value($value){ |
|
| 83 | - switch(true){ |
|
| 82 | + protected function parse_value($value) { |
|
| 83 | + switch (true) { |
|
| 84 | 84 | case $value instanceof \Carbon\Carbon: |
| 85 | 85 | $value = $value->format('d M y'); |
| 86 | 86 | break; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @throws MessageSearchValidationException |
| 98 | 98 | */ |
| 99 | 99 | protected function parse_date($date) { |
| 100 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 100 | + if ($date instanceof \Carbon\Carbon) return $date; |
|
| 101 | 101 | |
| 102 | 102 | try { |
| 103 | 103 | $date = Carbon::parse($date); |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | $available_messages = collect($available_messages); |
| 127 | 127 | $options = config('imap.options'); |
| 128 | 128 | |
| 129 | - if(strtolower($options['fetch_order']) === 'desc'){ |
|
| 129 | + if (strtolower($options['fetch_order']) === 'desc') { |
|
| 130 | 130 | $available_messages = $available_messages->reverse(); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $available_messages->forPage($this->page, $this->limit)->each(function($msgno, $msglist) use(&$messages, $options) { |
| 134 | 134 | $oMessage = new Message($msgno, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchAttachment()); |
| 135 | - switch ($options['message_key']){ |
|
| 135 | + switch ($options['message_key']) { |
|
| 136 | 136 | case 'number': |
| 137 | 137 | $message_key = $oMessage->getMessageNo(); |
| 138 | 138 | break; |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | if (count($statement) == 1) { |
| 168 | 168 | $query .= $statement[0]; |
| 169 | 169 | } else { |
| 170 | - if($statement[1] === null){ |
|
| 170 | + if ($statement[1] === null) { |
|
| 171 | 171 | $query .= $statement[0]; |
| 172 | - }else{ |
|
| 172 | + } else { |
|
| 173 | 173 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @return $this |
| 199 | 199 | */ |
| 200 | 200 | public function limit($limit, $page = 1) { |
| 201 | - if($page >= 1) $this->page = $page; |
|
| 201 | + if ($page >= 1) $this->page = $page; |
|
| 202 | 202 | $this->limit = $limit; |
| 203 | 203 | |
| 204 | 204 | return $this; |
@@ -97,7 +97,9 @@ discard block |
||
| 97 | 97 | * @throws MessageSearchValidationException |
| 98 | 98 | */ |
| 99 | 99 | protected function parse_date($date) { |
| 100 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 100 | + if($date instanceof \Carbon\Carbon) { |
|
| 101 | + return $date; |
|
| 102 | + } |
|
| 101 | 103 | |
| 102 | 104 | try { |
| 103 | 105 | $date = Carbon::parse($date); |
@@ -169,7 +171,7 @@ discard block |
||
| 169 | 171 | } else { |
| 170 | 172 | if($statement[1] === null){ |
| 171 | 173 | $query .= $statement[0]; |
| 172 | - }else{ |
|
| 174 | + } else{ |
|
| 173 | 175 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 174 | 176 | } |
| 175 | 177 | } |
@@ -198,7 +200,9 @@ discard block |
||
| 198 | 200 | * @return $this |
| 199 | 201 | */ |
| 200 | 202 | public function limit($limit, $page = 1) { |
| 201 | - if($page >= 1) $this->page = $page; |
|
| 203 | + if($page >= 1) { |
|
| 204 | + $this->page = $page; |
|
| 205 | + } |
|
| 202 | 206 | $this->limit = $limit; |
| 203 | 207 | |
| 204 | 208 | return $this; |