@@ -65,7 +65,7 @@ |
||
65 | 65 | * |
66 | 66 | * @return array |
67 | 67 | */ |
68 | - public function getEvents(){ |
|
68 | + public function getEvents() { |
|
69 | 69 | return $this->events; |
70 | 70 | } |
71 | 71 |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | |
77 | 77 | $name = Str::camel($name); |
78 | 78 | |
79 | - if(strtolower(substr($name, 0, 3)) === 'not') { |
|
79 | + if (strtolower(substr($name, 0, 3)) === 'not') { |
|
80 | 80 | $that = $that->whereNot(); |
81 | 81 | $name = substr($name, 3); |
82 | 82 | } |
83 | 83 | |
84 | - if (strpos(strtolower($name), "where") === false){ |
|
84 | + if (strpos(strtolower($name), "where") === false) { |
|
85 | 85 | $method = 'where'.ucfirst($name); |
86 | - }else{ |
|
86 | + }else { |
|
87 | 87 | $method = lcfirst($name); |
88 | 88 | } |
89 | 89 | |
90 | - if(method_exists($this, $method) === true){ |
|
90 | + if (method_exists($this, $method) === true) { |
|
91 | 91 | return call_user_func_array([$that, $method], $arguments); |
92 | 92 | } |
93 | 93 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | if (substr($criteria, 0, 7) === "CUSTOM ") { |
107 | 107 | return substr($criteria, 7); |
108 | 108 | } |
109 | - if(in_array($criteria, $this->available_criteria) === false) { |
|
109 | + if (in_array($criteria, $this->available_criteria) === false) { |
|
110 | 110 | throw new InvalidWhereQueryCriteriaException(); |
111 | 111 | } |
112 | 112 | |
@@ -121,20 +121,20 @@ discard block |
||
121 | 121 | * @throws InvalidWhereQueryCriteriaException |
122 | 122 | */ |
123 | 123 | public function where($criteria, $value = null) { |
124 | - if(is_array($criteria)){ |
|
125 | - foreach($criteria as $key => $value){ |
|
126 | - if(is_numeric($key)){ |
|
124 | + if (is_array($criteria)) { |
|
125 | + foreach ($criteria as $key => $value) { |
|
126 | + if (is_numeric($key)) { |
|
127 | 127 | return $this->where($value); |
128 | 128 | } |
129 | 129 | return $this->where($key, $value); |
130 | 130 | } |
131 | - }else{ |
|
131 | + }else { |
|
132 | 132 | $criteria = $this->validate_criteria($criteria); |
133 | 133 | $value = $this->parse_value($value); |
134 | 134 | |
135 | - if($value === null || $value === ''){ |
|
135 | + if ($value === null || $value === '') { |
|
136 | 136 | $this->query->push([$criteria]); |
137 | - }else{ |
|
137 | + }else { |
|
138 | 138 | $this->query->push([$criteria, $value]); |
139 | 139 | } |
140 | 140 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function orWhere(\Closure $closure = null) { |
151 | 151 | $this->query->push(['OR']); |
152 | - if($closure !== null) $closure($this); |
|
152 | + if ($closure !== null) $closure($this); |
|
153 | 153 | |
154 | 154 | return $this; |
155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function andWhere(\Closure $closure = null) { |
163 | 163 | $this->query->push(['AND']); |
164 | - if($closure !== null) $closure($this); |
|
164 | + if ($closure !== null) $closure($this); |
|
165 | 165 | |
166 | 166 | return $this; |
167 | 167 | } |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return WhereQuery |
402 | 402 | * @throws InvalidWhereQueryCriteriaException |
403 | 403 | */ |
404 | - public function whereNoXSpam(){ |
|
404 | + public function whereNoXSpam() { |
|
405 | 405 | return $this->where("CUSTOM X-Spam-Flag NO"); |
406 | 406 | } |
407 | 407 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @return WhereQuery |
410 | 410 | * @throws InvalidWhereQueryCriteriaException |
411 | 411 | */ |
412 | - public function whereIsXSpam(){ |
|
412 | + public function whereIsXSpam() { |
|
413 | 413 | return $this->where("CUSTOM X-Spam-Flag YES"); |
414 | 414 | } |
415 | 415 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | * @return WhereQuery |
420 | 420 | * @throws InvalidWhereQueryCriteriaException |
421 | 421 | */ |
422 | - public function whereLanguage($country_code){ |
|
422 | + public function whereLanguage($country_code) { |
|
423 | 423 | return $this->where("Content-Language $country_code"); |
424 | 424 | } |
425 | 425 | } |
426 | 426 | \ No newline at end of file |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | if (strpos(strtolower($name), "where") === false){ |
85 | 85 | $method = 'where'.ucfirst($name); |
86 | - }else{ |
|
86 | + } else{ |
|
87 | 87 | $method = lcfirst($name); |
88 | 88 | } |
89 | 89 | |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | } |
129 | 129 | return $this->where($key, $value); |
130 | 130 | } |
131 | - }else{ |
|
131 | + } else{ |
|
132 | 132 | $criteria = $this->validate_criteria($criteria); |
133 | 133 | $value = $this->parse_value($value); |
134 | 134 | |
135 | 135 | if($value === null || $value === ''){ |
136 | 136 | $this->query->push([$criteria]); |
137 | - }else{ |
|
137 | + } else{ |
|
138 | 138 | $this->query->push([$criteria, $value]); |
139 | 139 | } |
140 | 140 | } |
@@ -149,7 +149,9 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function orWhere(\Closure $closure = null) { |
151 | 151 | $this->query->push(['OR']); |
152 | - if($closure !== null) $closure($this); |
|
152 | + if($closure !== null) { |
|
153 | + $closure($this); |
|
154 | + } |
|
153 | 155 | |
154 | 156 | return $this; |
155 | 157 | } |
@@ -161,7 +163,9 @@ discard block |
||
161 | 163 | */ |
162 | 164 | public function andWhere(\Closure $closure = null) { |
163 | 165 | $this->query->push(['AND']); |
164 | - if($closure !== null) $closure($this); |
|
166 | + if($closure !== null) { |
|
167 | + $closure($this); |
|
168 | + } |
|
165 | 169 | |
166 | 170 | return $this; |
167 | 171 | } |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | public static function get($key, $default = null) { |
69 | 69 | $parts = explode('.', $key); |
70 | 70 | $value = null; |
71 | - foreach($parts as $part) { |
|
72 | - if($value === null) { |
|
73 | - if(isset(self::$config[$part])) { |
|
71 | + foreach ($parts as $part) { |
|
72 | + if ($value === null) { |
|
73 | + if (isset(self::$config[$part])) { |
|
74 | 74 | $value = self::$config[$part]; |
75 | - }else{ |
|
75 | + }else { |
|
76 | 76 | break; |
77 | 77 | } |
78 | - }else{ |
|
79 | - if(isset($value[$part])) { |
|
78 | + }else { |
|
79 | + if (isset($value[$part])) { |
|
80 | 80 | $value = $value[$part]; |
81 | - }else{ |
|
81 | + }else { |
|
82 | 82 | break; |
83 | 83 | } |
84 | 84 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function setConfig($config) { |
173 | 173 | |
174 | - if(is_array($config) === false) { |
|
174 | + if (is_array($config) === false) { |
|
175 | 175 | $config = require $config; |
176 | 176 | } |
177 | 177 | |
@@ -181,17 +181,17 @@ discard block |
||
181 | 181 | $vendor_config = require $path; |
182 | 182 | $config = $this->array_merge_recursive_distinct($vendor_config, $config); |
183 | 183 | |
184 | - if(is_array($config)){ |
|
185 | - if(isset($config['default'])){ |
|
186 | - if(isset($config['accounts']) && $config['default'] != false){ |
|
184 | + if (is_array($config)) { |
|
185 | + if (isset($config['default'])) { |
|
186 | + if (isset($config['accounts']) && $config['default'] != false) { |
|
187 | 187 | |
188 | 188 | $default_config = $vendor_config['accounts']['default']; |
189 | - if(isset($config['accounts'][$config['default']])){ |
|
189 | + if (isset($config['accounts'][$config['default']])) { |
|
190 | 190 | $default_config = array_merge($default_config, $config['accounts'][$config['default']]); |
191 | 191 | } |
192 | 192 | |
193 | - if(is_array($config['accounts'])){ |
|
194 | - foreach($config['accounts'] as $account_key => $account){ |
|
193 | + if (is_array($config['accounts'])) { |
|
194 | + foreach ($config['accounts'] as $account_key => $account) { |
|
195 | 195 | $config['accounts'][$account_key] = array_merge($default_config, $account); |
196 | 196 | } |
197 | 197 | } |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | $arrays = func_get_args(); |
228 | 228 | $base = array_shift($arrays); |
229 | 229 | |
230 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
230 | + if (!is_array($base)) $base = empty($base) ? array() : array($base); |
|
231 | 231 | |
232 | - foreach($arrays as $append) { |
|
232 | + foreach ($arrays as $append) { |
|
233 | 233 | |
234 | - if(!is_array($append)) $append = array($append); |
|
234 | + if (!is_array($append)) $append = array($append); |
|
235 | 235 | |
236 | - foreach($append as $key => $value) { |
|
236 | + foreach ($append as $key => $value) { |
|
237 | 237 | |
238 | - if(!array_key_exists($key, $base) and !is_numeric($key)) { |
|
238 | + if (!array_key_exists($key, $base) and !is_numeric($key)) { |
|
239 | 239 | $base[$key] = $append[$key]; |
240 | 240 | continue; |
241 | 241 | } |
242 | 242 | |
243 | - if(is_array($value) or is_array($base[$key])) { |
|
243 | + if (is_array($value) or is_array($base[$key])) { |
|
244 | 244 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]); |
245 | - } else if(is_numeric($key)) { |
|
246 | - if(!in_array($value, $base)) $base[] = $value; |
|
247 | - } else { |
|
245 | + }else if (is_numeric($key)) { |
|
246 | + if (!in_array($value, $base)) $base[] = $value; |
|
247 | + }else { |
|
248 | 248 | $base[$key] = $value; |
249 | 249 | } |
250 | 250 |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | if($value === null) { |
73 | 73 | if(isset(self::$config[$part])) { |
74 | 74 | $value = self::$config[$part]; |
75 | - }else{ |
|
75 | + } else{ |
|
76 | 76 | break; |
77 | 77 | } |
78 | - }else{ |
|
78 | + } else{ |
|
79 | 79 | if(isset($value[$part])) { |
80 | 80 | $value = $value[$part]; |
81 | - }else{ |
|
81 | + } else{ |
|
82 | 82 | break; |
83 | 83 | } |
84 | 84 | } |
@@ -227,11 +227,15 @@ discard block |
||
227 | 227 | $arrays = func_get_args(); |
228 | 228 | $base = array_shift($arrays); |
229 | 229 | |
230 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
230 | + if(!is_array($base)) { |
|
231 | + $base = empty($base) ? array() : array($base); |
|
232 | + } |
|
231 | 233 | |
232 | 234 | foreach($arrays as $append) { |
233 | 235 | |
234 | - if(!is_array($append)) $append = array($append); |
|
236 | + if(!is_array($append)) { |
|
237 | + $append = array($append); |
|
238 | + } |
|
235 | 239 | |
236 | 240 | foreach($append as $key => $value) { |
237 | 241 | |
@@ -243,7 +247,9 @@ discard block |
||
243 | 247 | if(is_array($value) or is_array($base[$key])) { |
244 | 248 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]); |
245 | 249 | } else if(is_numeric($key)) { |
246 | - if(!in_array($value, $base)) $base[] = $value; |
|
250 | + if(!in_array($value, $base)) { |
|
251 | + $base[] = $value; |
|
252 | + } |
|
247 | 253 | } else { |
248 | 254 | $base[$key] = $value; |
249 | 255 | } |
@@ -26,8 +26,8 @@ |
||
26 | 26 | </tr> |
27 | 27 | </thead> |
28 | 28 | <tbody> |
29 | - <?php if($paginator->count() > 0): ?> |
|
30 | - <?php foreach($paginator as $message): ?> |
|
29 | + <?php if ($paginator->count() > 0): ?> |
|
30 | + <?php foreach ($paginator as $message): ?> |
|
31 | 31 | <tr> |
32 | 32 | <td><?php echo $message->getUid(); ?></td> |
33 | 33 | <td><?php echo $message->getSubject(); ?></td> |
@@ -35,11 +35,14 @@ |
||
35 | 35 | <td><?php echo $message->getAttachments()->count() > 0 ? 'yes' : 'no'; ?></td> |
36 | 36 | </tr> |
37 | 37 | <?php endforeach; ?> |
38 | - <?php else: ?> |
|
38 | + <?php else { |
|
39 | + : ?> |
|
39 | 40 | <tr> |
40 | 41 | <td colspan="4">No messages found</td> |
41 | 42 | </tr> |
42 | - <?php endif; ?> |
|
43 | + <?php endif; |
|
44 | +} |
|
45 | +?> |
|
43 | 46 | </tbody> |
44 | 47 | </table> |
45 | 48 |
@@ -24,8 +24,8 @@ |
||
24 | 24 | </tr> |
25 | 25 | </thead> |
26 | 26 | <tbody> |
27 | - <?php if($paginator->count() > 0): ?> |
|
28 | - <?php foreach($paginator as $folder): ?> |
|
27 | + <?php if ($paginator->count() > 0): ?> |
|
28 | + <?php foreach ($paginator as $folder): ?> |
|
29 | 29 | <tr> |
30 | 30 | <td><?php echo $folder->name; ?></td> |
31 | 31 | <td><?php echo $folder->search()->unseen()->setFetchBody(false)->count(); ?></td> |
@@ -31,11 +31,14 @@ |
||
31 | 31 | <td><?php echo $folder->search()->unseen()->setFetchBody(false)->count(); ?></td> |
32 | 32 | </tr> |
33 | 33 | <?php endforeach; ?> |
34 | - <?php else: ?> |
|
34 | + <?php else { |
|
35 | + : ?> |
|
35 | 36 | <tr> |
36 | 37 | <td colspan="4">No folders found</td> |
37 | 38 | </tr> |
38 | - <?php endif; ?> |
|
39 | + <?php endif; |
|
40 | +} |
|
41 | +?> |
|
39 | 42 | </tbody> |
40 | 43 | </table> |
41 | 44 |
@@ -121,7 +121,7 @@ |
||
121 | 121 | protected function parse(){ |
122 | 122 | if ($this->header === null) { |
123 | 123 | $body = $this->findHeaders(); |
124 | - }else{ |
|
124 | + } else{ |
|
125 | 125 | $body = $this->raw; |
126 | 126 | } |
127 | 127 |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @throws InvalidMessageDateException |
161 | 161 | */ |
162 | - protected function parse(){ |
|
162 | + protected function parse() { |
|
163 | 163 | if ($this->header === null) { |
164 | 164 | $body = $this->findHeaders(); |
165 | - }else{ |
|
165 | + }else { |
|
166 | 166 | $body = $this->raw; |
167 | 167 | } |
168 | 168 | |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | $this->name = $this->header->get("name"); |
176 | 176 | $this->filename = $this->header->get("filename"); |
177 | 177 | |
178 | - if(!empty($this->header->get("id"))) { |
|
178 | + if (!empty($this->header->get("id"))) { |
|
179 | 179 | $this->id = $this->header->get("id"); |
180 | - } else if(!empty($this->header->get("x-attachment-id"))){ |
|
180 | + }else if (!empty($this->header->get("x-attachment-id"))) { |
|
181 | 181 | $this->id = $this->header->get("x-attachment-id"); |
182 | - } else if(!empty($this->header->get("content-id"))){ |
|
182 | + }else if (!empty($this->header->get("content-id"))) { |
|
183 | 183 | $this->id = strtr($this->header->get("content-id"), [ |
184 | 184 | '<' => '', |
185 | 185 | '>' => '' |
186 | 186 | ]); |
187 | 187 | } |
188 | 188 | |
189 | - if(!empty($this->header->get("content-type"))){ |
|
189 | + if (!empty($this->header->get("content-type"))) { |
|
190 | 190 | $rawContentType = $this->header->get("content-type"); |
191 | 191 | $contentTypeArray = explode(';', $rawContentType); |
192 | 192 | $this->content_type = trim($contentTypeArray[0]); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @return string |
204 | 204 | * @throws InvalidMessageDateException |
205 | 205 | */ |
206 | - private function findHeaders(){ |
|
206 | + private function findHeaders() { |
|
207 | 207 | $body = $this->raw; |
208 | 208 | while (($pos = strpos($body, "\r\n")) > 0) { |
209 | 209 | $body = substr($body, $pos + 2); |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | /** |
220 | 220 | * Try to parse the subtype if any is present |
221 | 221 | */ |
222 | - private function parseSubtype(){ |
|
222 | + private function parseSubtype() { |
|
223 | 223 | $content_type = $this->header->get("content-type"); |
224 | - if (($pos = strpos($content_type, "/")) !== false){ |
|
224 | + if (($pos = strpos($content_type, "/")) !== false) { |
|
225 | 225 | $this->subtype = substr($content_type, $pos + 1); |
226 | 226 | } |
227 | 227 | } |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | /** |
230 | 230 | * Try to parse the disposition if any is present |
231 | 231 | */ |
232 | - private function parseDisposition(){ |
|
232 | + private function parseDisposition() { |
|
233 | 233 | $content_disposition = $this->header->get("content-disposition"); |
234 | - if($content_disposition !== null) { |
|
234 | + if ($content_disposition !== null) { |
|
235 | 235 | $this->ifdisposition = true; |
236 | 236 | $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition; |
237 | 237 | } |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | /** |
241 | 241 | * Try to parse the description if any is present |
242 | 242 | */ |
243 | - private function parseDescription(){ |
|
243 | + private function parseDescription() { |
|
244 | 244 | $content_description = $this->header->get("content-description"); |
245 | - if($content_description !== null) { |
|
245 | + if ($content_description !== null) { |
|
246 | 246 | $this->ifdescription = true; |
247 | 247 | $this->description = $content_description; |
248 | 248 | } |
@@ -251,9 +251,9 @@ discard block |
||
251 | 251 | /** |
252 | 252 | * Try to parse the encoding if any is present |
253 | 253 | */ |
254 | - private function parseEncoding(){ |
|
254 | + private function parseEncoding() { |
|
255 | 255 | $encoding = $this->header->get("content-transfer-encoding"); |
256 | - if($encoding !== null) { |
|
256 | + if ($encoding !== null) { |
|
257 | 257 | switch (strtolower($encoding)) { |
258 | 258 | case "quoted-printable": |
259 | 259 | $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE; |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | * @param array $config |
177 | 177 | * @param array $default_config |
178 | 178 | */ |
179 | - private function setAccountConfig($key, $config, $default_config){ |
|
179 | + private function setAccountConfig($key, $config, $default_config) { |
|
180 | 180 | $value = $this->default_account_config[$key]; |
181 | - if(isset($config[$key])) { |
|
181 | + if (isset($config[$key])) { |
|
182 | 182 | $value = $config[$key]; |
183 | - }elseif(isset($default_config[$key])) { |
|
183 | + }elseif (isset($default_config[$key])) { |
|
184 | 184 | $value = $default_config[$key]; |
185 | 185 | } |
186 | 186 | $this->$key = $value; |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function setEventsFromConfig($config) { |
194 | 194 | $this->events = ClientManager::get("events"); |
195 | - if(isset($config['events'])){ |
|
196 | - if(isset($config['events'])) { |
|
197 | - foreach($config['events'] as $section => $events) { |
|
195 | + if (isset($config['events'])) { |
|
196 | + if (isset($config['events'])) { |
|
197 | + foreach ($config['events'] as $section => $events) { |
|
198 | 198 | $this->events[$section] = array_merge($this->events[$section], $events); |
199 | 199 | } |
200 | 200 | } |
@@ -208,45 +208,45 @@ discard block |
||
208 | 208 | * @throws MaskNotFoundException |
209 | 209 | */ |
210 | 210 | protected function setMaskFromConfig($config) { |
211 | - $default_config = ClientManager::get("masks"); |
|
211 | + $default_config = ClientManager::get("masks"); |
|
212 | 212 | |
213 | - if(isset($config['masks'])){ |
|
214 | - if(isset($config['masks']['message'])) { |
|
215 | - if(class_exists($config['masks']['message'])) { |
|
213 | + if (isset($config['masks'])) { |
|
214 | + if (isset($config['masks']['message'])) { |
|
215 | + if (class_exists($config['masks']['message'])) { |
|
216 | 216 | $this->default_message_mask = $config['masks']['message']; |
217 | - }else{ |
|
217 | + }else { |
|
218 | 218 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
219 | 219 | } |
220 | - }else{ |
|
221 | - if(class_exists($default_config['message'])) { |
|
220 | + }else { |
|
221 | + if (class_exists($default_config['message'])) { |
|
222 | 222 | $this->default_message_mask = $default_config['message']; |
223 | - }else{ |
|
223 | + }else { |
|
224 | 224 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
225 | 225 | } |
226 | 226 | } |
227 | - if(isset($config['masks']['attachment'])) { |
|
228 | - if(class_exists($config['masks']['attachment'])) { |
|
227 | + if (isset($config['masks']['attachment'])) { |
|
228 | + if (class_exists($config['masks']['attachment'])) { |
|
229 | 229 | $this->default_message_mask = $config['masks']['attachment']; |
230 | - }else{ |
|
230 | + }else { |
|
231 | 231 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
232 | 232 | } |
233 | - }else{ |
|
234 | - if(class_exists($default_config['attachment'])) { |
|
233 | + }else { |
|
234 | + if (class_exists($default_config['attachment'])) { |
|
235 | 235 | $this->default_message_mask = $default_config['attachment']; |
236 | - }else{ |
|
236 | + }else { |
|
237 | 237 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
238 | 238 | } |
239 | 239 | } |
240 | - }else{ |
|
241 | - if(class_exists($default_config['message'])) { |
|
240 | + }else { |
|
241 | + if (class_exists($default_config['message'])) { |
|
242 | 242 | $this->default_message_mask = $default_config['message']; |
243 | - }else{ |
|
243 | + }else { |
|
244 | 244 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
245 | 245 | } |
246 | 246 | |
247 | - if(class_exists($default_config['attachment'])) { |
|
247 | + if (class_exists($default_config['attachment'])) { |
|
248 | 248 | $this->default_message_mask = $default_config['attachment']; |
249 | - }else{ |
|
249 | + }else { |
|
250 | 250 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
251 | 251 | } |
252 | 252 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $timeout = $this->connection !== false ? $this->connection->getConnectionTimeout() : null; |
311 | 311 | $this->connection = new ImapProtocol($this->validate_cert); |
312 | 312 | $this->connection->setConnectionTimeout($timeout); |
313 | - }else{ |
|
313 | + }else { |
|
314 | 314 | if (extension_loaded('imap') === false) { |
315 | 315 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
316 | 316 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
388 | 388 | $items = $this->connection->folders('', $pattern); |
389 | 389 | |
390 | - if(is_array($items)){ |
|
390 | + if (is_array($items)) { |
|
391 | 391 | foreach ($items as $folder_name => $item) { |
392 | 392 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
393 | 393 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | return $folders; |
405 | - }else{ |
|
405 | + }else { |
|
406 | 406 | throw new FolderFetchingException("failed to fetch any folders"); |
407 | 407 | } |
408 | 408 | } |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | public function createFolder($folder, $expunge = true) { |
437 | 437 | $this->checkConnection(); |
438 | 438 | $status = $this->connection->createFolder($folder); |
439 | - if($expunge) $this->expunge(); |
|
439 | + if ($expunge) $this->expunge(); |
|
440 | 440 | |
441 | 441 | $folder = $this->getFolder($folder); |
442 | - if($status && $folder) { |
|
442 | + if ($status && $folder) { |
|
443 | 443 | $event = $this->getEvent("folder", "new"); |
444 | 444 | $event::dispatch($folder); |
445 | 445 | } |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @return Folder |
466 | 466 | */ |
467 | - public function getFolderPath(){ |
|
467 | + public function getFolderPath() { |
|
468 | 468 | return $this->active_folder; |
469 | 469 | } |
470 | 470 | |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * |
519 | 519 | * @return int |
520 | 520 | */ |
521 | - public function getTimeout($type){ |
|
521 | + public function getTimeout($type) { |
|
522 | 522 | return $this->connection->getConnectionTimeout(); |
523 | 523 | } |
524 | 524 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @return string |
529 | 529 | */ |
530 | - public function getDefaultMessageMask(){ |
|
530 | + public function getDefaultMessageMask() { |
|
531 | 531 | return $this->default_message_mask; |
532 | 532 | } |
533 | 533 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * |
538 | 538 | * @return array |
539 | 539 | */ |
540 | - public function getDefaultEvents($section){ |
|
540 | + public function getDefaultEvents($section) { |
|
541 | 541 | return $this->events[$section]; |
542 | 542 | } |
543 | 543 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * @throws MaskNotFoundException |
550 | 550 | */ |
551 | 551 | public function setDefaultMessageMask($mask) { |
552 | - if(class_exists($mask)) { |
|
552 | + if (class_exists($mask)) { |
|
553 | 553 | $this->default_message_mask = $mask; |
554 | 554 | |
555 | 555 | return $this; |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @return string |
565 | 565 | */ |
566 | - public function getDefaultAttachmentMask(){ |
|
566 | + public function getDefaultAttachmentMask() { |
|
567 | 567 | return $this->default_attachment_mask; |
568 | 568 | } |
569 | 569 | |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @throws MaskNotFoundException |
576 | 576 | */ |
577 | 577 | public function setDefaultAttachmentMask($mask) { |
578 | - if(class_exists($mask)) { |
|
578 | + if (class_exists($mask)) { |
|
579 | 579 | $this->default_attachment_mask = $mask; |
580 | 580 | |
581 | 581 | return $this; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $value = $this->default_account_config[$key]; |
181 | 181 | if(isset($config[$key])) { |
182 | 182 | $value = $config[$key]; |
183 | - }elseif(isset($default_config[$key])) { |
|
183 | + } elseif(isset($default_config[$key])) { |
|
184 | 184 | $value = $default_config[$key]; |
185 | 185 | } |
186 | 186 | $this->$key = $value; |
@@ -214,39 +214,39 @@ discard block |
||
214 | 214 | if(isset($config['masks']['message'])) { |
215 | 215 | if(class_exists($config['masks']['message'])) { |
216 | 216 | $this->default_message_mask = $config['masks']['message']; |
217 | - }else{ |
|
217 | + } else{ |
|
218 | 218 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
219 | 219 | } |
220 | - }else{ |
|
220 | + } else{ |
|
221 | 221 | if(class_exists($default_config['message'])) { |
222 | 222 | $this->default_message_mask = $default_config['message']; |
223 | - }else{ |
|
223 | + } else{ |
|
224 | 224 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
225 | 225 | } |
226 | 226 | } |
227 | 227 | if(isset($config['masks']['attachment'])) { |
228 | 228 | if(class_exists($config['masks']['attachment'])) { |
229 | 229 | $this->default_message_mask = $config['masks']['attachment']; |
230 | - }else{ |
|
230 | + } else{ |
|
231 | 231 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
232 | 232 | } |
233 | - }else{ |
|
233 | + } else{ |
|
234 | 234 | if(class_exists($default_config['attachment'])) { |
235 | 235 | $this->default_message_mask = $default_config['attachment']; |
236 | - }else{ |
|
236 | + } else{ |
|
237 | 237 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
238 | 238 | } |
239 | 239 | } |
240 | - }else{ |
|
240 | + } else{ |
|
241 | 241 | if(class_exists($default_config['message'])) { |
242 | 242 | $this->default_message_mask = $default_config['message']; |
243 | - }else{ |
|
243 | + } else{ |
|
244 | 244 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
245 | 245 | } |
246 | 246 | |
247 | 247 | if(class_exists($default_config['attachment'])) { |
248 | 248 | $this->default_message_mask = $default_config['attachment']; |
249 | - }else{ |
|
249 | + } else{ |
|
250 | 250 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
251 | 251 | } |
252 | 252 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $timeout = $this->connection !== false ? $this->connection->getConnectionTimeout() : null; |
311 | 311 | $this->connection = new ImapProtocol($this->validate_cert); |
312 | 312 | $this->connection->setConnectionTimeout($timeout); |
313 | - }else{ |
|
313 | + } else{ |
|
314 | 314 | if (extension_loaded('imap') === false) { |
315 | 315 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
316 | 316 | } |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | return $folders; |
405 | - }else{ |
|
405 | + } else{ |
|
406 | 406 | throw new FolderFetchingException("failed to fetch any folders"); |
407 | 407 | } |
408 | 408 | } |
@@ -436,7 +436,9 @@ discard block |
||
436 | 436 | public function createFolder($folder, $expunge = true) { |
437 | 437 | $this->checkConnection(); |
438 | 438 | $status = $this->connection->createFolder($folder); |
439 | - if($expunge) $this->expunge(); |
|
439 | + if($expunge) { |
|
440 | + $this->expunge(); |
|
441 | + } |
|
440 | 442 | |
441 | 443 | $folder = $this->getFolder($folder); |
442 | 444 | if($status && $folder) { |
@@ -376,7 +376,7 @@ |
||
376 | 376 | if (strpos($folder_name, $delimiter) !== false) { |
377 | 377 | return $this->getFolderByPath($folder_name); |
378 | 378 | } |
379 | - } |
|
379 | + } |
|
380 | 380 | |
381 | 381 | return $this->getFolderByName($folder_name); |
382 | 382 | } |
@@ -252,7 +252,7 @@ |
||
252 | 252 | */ |
253 | 253 | public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
254 | 254 | if ( |
255 | - $page === null |
|
255 | + $page === null |
|
256 | 256 | && isset($_GET[$page_name]) |
257 | 257 | && $_GET[$page_name] > 0 |
258 | 258 | ) { |
@@ -73,7 +73,9 @@ discard block |
||
73 | 73 | public function __construct(Client $client, $charset = 'UTF-8') { |
74 | 74 | $this->setClient($client); |
75 | 75 | |
76 | - if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
76 | + if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
77 | + $this->leaveUnread(); |
|
78 | + } |
|
77 | 79 | |
78 | 80 | $this->date_format = ClientManager::get('date_format', 'd M y'); |
79 | 81 | |
@@ -111,7 +113,9 @@ discard block |
||
111 | 113 | * @throws MessageSearchValidationException |
112 | 114 | */ |
113 | 115 | protected function parse_date($date) { |
114 | - if($date instanceof \Carbon\Carbon) return $date; |
|
116 | + if($date instanceof \Carbon\Carbon) { |
|
117 | + return $date; |
|
118 | + } |
|
115 | 119 | |
116 | 120 | try { |
117 | 121 | $date = Carbon::parse($date); |
@@ -286,7 +290,7 @@ discard block |
||
286 | 290 | } else { |
287 | 291 | if($statement[1] === null){ |
288 | 292 | $query .= $statement[0]; |
289 | - }else{ |
|
293 | + } else{ |
|
290 | 294 | $query .= $statement[0].' "'.$statement[1].'"'; |
291 | 295 | } |
292 | 296 | } |
@@ -316,7 +320,9 @@ discard block |
||
316 | 320 | * @return $this |
317 | 321 | */ |
318 | 322 | public function limit($limit, $page = 1) { |
319 | - if($page >= 1) $this->page = $page; |
|
323 | + if($page >= 1) { |
|
324 | + $this->page = $page; |
|
325 | + } |
|
320 | 326 | $this->limit = $limit; |
321 | 327 | |
322 | 328 | return $this; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function __construct(Client $client, $charset = 'UTF-8') { |
74 | 74 | $this->setClient($client); |
75 | 75 | |
76 | - if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
76 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
77 | 77 | |
78 | 78 | $this->date_format = ClientManager::get('date_format', 'd M y'); |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Instance boot method for additional functionality |
87 | 87 | */ |
88 | - protected function boot(){} |
|
88 | + protected function boot() {} |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Parse a given value |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return string |
95 | 95 | */ |
96 | - protected function parse_value($value){ |
|
97 | - switch(true){ |
|
96 | + protected function parse_value($value) { |
|
97 | + switch (true) { |
|
98 | 98 | case $value instanceof \Carbon\Carbon: |
99 | 99 | $value = $value->format($this->date_format); |
100 | 100 | break; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @throws MessageSearchValidationException |
112 | 112 | */ |
113 | 113 | protected function parse_date($date) { |
114 | - if($date instanceof \Carbon\Carbon) return $date; |
|
114 | + if ($date instanceof \Carbon\Carbon) return $date; |
|
115 | 115 | |
116 | 116 | try { |
117 | 117 | $date = Carbon::parse($date); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return Collection |
151 | 151 | * @throws GetMessagesFailedException |
152 | 152 | */ |
153 | - protected function search(){ |
|
153 | + protected function search() { |
|
154 | 154 | $this->generate_query(); |
155 | 155 | |
156 | 156 | try { |
@@ -195,15 +195,15 @@ discard block |
||
195 | 195 | |
196 | 196 | $options = ClientManager::get('options'); |
197 | 197 | |
198 | - if(strtolower($options['fetch_order']) === 'desc'){ |
|
198 | + if (strtolower($options['fetch_order']) === 'desc') { |
|
199 | 199 | $available_messages = $available_messages->reverse(); |
200 | 200 | } |
201 | 201 | |
202 | - $query =& $this; |
|
202 | + $query = & $this; |
|
203 | 203 | |
204 | 204 | $available_messages->forPage($this->page, $this->limit)->each(function($msgno, $msglist) use(&$messages, $options, $query) { |
205 | 205 | $message = $query->getMessage($msgno, $msglist); |
206 | - switch ($options['message_key']){ |
|
206 | + switch ($options['message_key']) { |
|
207 | 207 | case 'number': |
208 | 208 | $message_key = $message->getMessageNo(); |
209 | 209 | break; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | return $messages; |
223 | 223 | } catch (\Exception $e) { |
224 | - throw new GetMessagesFailedException($e->getMessage(),0, $e); |
|
224 | + throw new GetMessagesFailedException($e->getMessage(), 0, $e); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @throws MessageHeaderFetchingException |
239 | 239 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
240 | 240 | */ |
241 | - public function getMessage($msgno, $msglist = null){ |
|
241 | + public function getMessage($msgno, $msglist = null) { |
|
242 | 242 | return new Message($msgno, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags()); |
243 | 243 | } |
244 | 244 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return LengthAwarePaginator |
252 | 252 | * @throws GetMessagesFailedException |
253 | 253 | */ |
254 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
254 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
255 | 255 | if ( |
256 | 256 | $page === null |
257 | 257 | && isset($_GET[$page_name]) |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | $this->query->each(function($statement) use(&$query) { |
278 | 278 | if (count($statement) == 1) { |
279 | 279 | $query .= $statement[0]; |
280 | - } else { |
|
281 | - if($statement[1] === null){ |
|
280 | + }else { |
|
281 | + if ($statement[1] === null) { |
|
282 | 282 | $query .= $statement[0]; |
283 | - }else{ |
|
283 | + }else { |
|
284 | 284 | $query .= $statement[0].' "'.$statement[1].'"'; |
285 | 285 | } |
286 | 286 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @return $this |
311 | 311 | */ |
312 | 312 | public function limit($limit, $page = 1) { |
313 | - if($page >= 1) $this->page = $page; |
|
313 | + if ($page >= 1) $this->page = $page; |
|
314 | 314 | $this->limit = $limit; |
315 | 315 | |
316 | 316 | return $this; |
@@ -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,10 +85,10 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Determine the message content type |
87 | 87 | */ |
88 | - public function findContentType(){ |
|
89 | - if(stripos($this->header->get("content-type"), 'multipart') === 0) { |
|
88 | + public function findContentType() { |
|
89 | + if (stripos($this->header->get("content-type"), 'multipart') === 0) { |
|
90 | 90 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
91 | - }else{ |
|
91 | + }else { |
|
92 | 92 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
93 | 93 | } |
94 | 94 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * Determine the message content type |
98 | 98 | */ |
99 | - public function getBoundary(){ |
|
99 | + public function getBoundary() { |
|
100 | 100 | return $this->header->find("/boundary\=\"(.*)\"/"); |
101 | 101 | } |
102 | 102 | |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | * @throws MessageContentFetchingException |
108 | 108 | * @throws InvalidMessageDateException |
109 | 109 | */ |
110 | - public function find_parts(){ |
|
111 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
112 | - if (($boundary = $this->getBoundary()) === null) { |
|
110 | + public function find_parts() { |
|
111 | + if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
112 | + if (($boundary = $this->getBoundary()) === null) { |
|
113 | 113 | throw new MessageContentFetchingException("no content found", 0); |
114 | 114 | } |
115 | 115 | |
@@ -118,21 +118,21 @@ discard block |
||
118 | 118 | ]; |
119 | 119 | |
120 | 120 | if (preg_match("/boundary\=\"(.*)\"/", $this->raw, $match) == 1) { |
121 | - if(is_array($match[1])){ |
|
122 | - foreach($match[1] as $matched){ |
|
121 | + if (is_array($match[1])) { |
|
122 | + foreach ($match[1] as $matched) { |
|
123 | 123 | $boundaries[] = $matched; |
124 | 124 | } |
125 | - }else{ |
|
126 | - if(!empty($match[1])) { |
|
125 | + }else { |
|
126 | + if (!empty($match[1])) { |
|
127 | 127 | $boundaries[] = $match[1]; |
128 | 128 | } |
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | - $raw_parts = explode( $boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw) ); |
|
132 | + $raw_parts = explode($boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw)); |
|
133 | 133 | $parts = []; |
134 | 134 | $part_number = 0; |
135 | - foreach($raw_parts as $part) { |
|
135 | + foreach ($raw_parts as $part) { |
|
136 | 136 | $part = trim(rtrim($part)); |
137 | 137 | if ($part !== "--") { |
138 | 138 | $parts[] = new Part($part, null, $part_number); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function findContentType(){ |
89 | 89 | if(stripos($this->header->get("content-type"), 'multipart') === 0) { |
90 | 90 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
91 | - }else{ |
|
91 | + } else{ |
|
92 | 92 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
93 | 93 | } |
94 | 94 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | foreach($match[1] as $matched){ |
123 | 123 | $boundaries[] = $matched; |
124 | 124 | } |
125 | - }else{ |
|
125 | + } else{ |
|
126 | 126 | if(!empty($match[1])) { |
127 | 127 | $boundaries[] = $match[1]; |
128 | 128 | } |