@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | public function offsetSet($offset, $value): void { |
114 | 114 | if (is_null($offset)) { |
115 | 115 | $this->values[] = $value; |
116 | - } else { |
|
116 | + }else { |
|
117 | 117 | $this->values[$offset] = $value; |
118 | 118 | } |
119 | 119 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | if ($this->contains($value) === false) { |
181 | 181 | $this->values[] = $value; |
182 | 182 | } |
183 | - }else{ |
|
183 | + }else { |
|
184 | 184 | $this->values[] = $value; |
185 | 185 | } |
186 | 186 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return mixed|null |
229 | 229 | */ |
230 | - public function first(){ |
|
230 | + public function first() { |
|
231 | 231 | if ($this->offsetExists(0)) { |
232 | 232 | return $this->values[0]; |
233 | 233 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return mixed|null |
241 | 241 | */ |
242 | - public function last(){ |
|
242 | + public function last() { |
|
243 | 243 | if (($cnt = $this->count()) > 0) { |
244 | 244 | return $this->values[$cnt - 1]; |
245 | 245 | } |
@@ -77,7 +77,9 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function toDate(): Carbon { |
79 | 79 | $date = $this->first(); |
80 | - if ($date instanceof Carbon) return $date; |
|
80 | + if ($date instanceof Carbon) { |
|
81 | + return $date; |
|
82 | + } |
|
81 | 83 | |
82 | 84 | return Carbon::parse($date); |
83 | 85 | } |
@@ -180,7 +182,7 @@ discard block |
||
180 | 182 | if ($this->contains($value) === false) { |
181 | 183 | $this->values[] = $value; |
182 | 184 | } |
183 | - }else{ |
|
185 | + } else{ |
|
184 | 186 | $this->values[] = $value; |
185 | 187 | } |
186 | 188 | } |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | if (strpos(strtolower($name), "where") === false) { |
88 | - $method = 'where' . ucfirst($name); |
|
89 | - } else { |
|
88 | + $method = 'where'.ucfirst($name); |
|
89 | + }else { |
|
90 | 90 | $method = lcfirst($name); |
91 | 91 | } |
92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | return call_user_func_array([$that, $method], $arguments); |
95 | 95 | } |
96 | 96 | |
97 | - throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported'); |
|
97 | + throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | foreach ($criteria as $key => $value) { |
138 | 138 | if (is_numeric($key)) { |
139 | 139 | $this->where($value); |
140 | - }else{ |
|
140 | + }else { |
|
141 | 141 | $this->where($key, $value); |
142 | 142 | } |
143 | 143 | } |
144 | - } else { |
|
144 | + }else { |
|
145 | 145 | $this->push_search_criteria($criteria, $value); |
146 | 146 | } |
147 | 147 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | if ($value === null || $value === '') { |
163 | 163 | $this->query->push([$criteria]); |
164 | - } else { |
|
164 | + }else { |
|
165 | 165 | $this->query->push([$criteria, $value]); |
166 | 166 | } |
167 | 167 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | foreach ($criteria as $key => $value) { |
138 | 138 | if (is_numeric($key)) { |
139 | 139 | $this->where($value); |
140 | - }else{ |
|
140 | + } else{ |
|
141 | 141 | $this->where($key, $value); |
142 | 142 | } |
143 | 143 | } |
@@ -173,7 +173,9 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function orWhere(Closure $closure = null): self { |
175 | 175 | $this->query->push(['OR']); |
176 | - if ($closure !== null) $closure($this); |
|
176 | + if ($closure !== null) { |
|
177 | + $closure($this); |
|
178 | + } |
|
177 | 179 | |
178 | 180 | return $this; |
179 | 181 | } |
@@ -185,7 +187,9 @@ discard block |
||
185 | 187 | */ |
186 | 188 | public function andWhere(Closure $closure = null): self { |
187 | 189 | $this->query->push(['AND']); |
188 | - if ($closure !== null) $closure($this); |
|
190 | + if ($closure !== null) { |
|
191 | + $closure($this); |
|
192 | + } |
|
189 | 193 | |
190 | 194 | return $this; |
191 | 195 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | if (ClientManager::get('options.fetch_order') === 'desc') { |
87 | 87 | $this->fetch_order = 'desc'; |
88 | - } else { |
|
88 | + }else { |
|
89 | 89 | $this->fetch_order = 'asc'; |
90 | 90 | } |
91 | 91 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | break; |
117 | 117 | } |
118 | 118 | |
119 | - return (string)$value; |
|
119 | + return (string) $value; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | $this->query->each(function($statement) use (&$query): void { |
149 | 149 | if ((is_countable($statement) ? count($statement) : 0) == 1) { |
150 | 150 | $query .= $statement[0]; |
151 | - } else { |
|
151 | + }else { |
|
152 | 152 | if ($statement[1] === null) { |
153 | 153 | $query .= $statement[0]; |
154 | - } else { |
|
154 | + }else { |
|
155 | 155 | if (is_numeric($statement[1])) { |
156 | - $query .= $statement[0] . ' ' . $statement[1]; |
|
157 | - } else { |
|
158 | - $query .= $statement[0] . ' "' . $statement[1] . '"'; |
|
156 | + $query .= $statement[0].' '.$statement[1]; |
|
157 | + }else { |
|
158 | + $query .= $statement[0].' "'.$statement[1].'"'; |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | try { |
181 | 181 | $available_messages = $this->client->getConnection()->search([$this->getRawQuery()], $this->sequence); |
182 | 182 | return $available_messages !== false ? new Collection($available_messages) : new Collection(); |
183 | - } catch (RuntimeException|ConnectionFailedException $e) { |
|
183 | + } catch (RuntimeException | ConnectionFailedException $e) { |
|
184 | 184 | throw new GetMessagesFailedException("failed to fetch messages", 0, $e); |
185 | 185 | } |
186 | 186 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | protected function make(int $uid, int $msglist, string $header, string $content, array $flags) { |
247 | 247 | try { |
248 | 248 | return Message::make($uid, $msglist, $this->getClient(), $header, $content, $flags, $this->getFetchOptions(), $this->sequence); |
249 | - } catch (MessageNotFoundException|RuntimeException|MessageFlagException|InvalidMessageDateException|MessageContentFetchingException $e) { |
|
249 | + } catch (MessageNotFoundException | RuntimeException | MessageFlagException | InvalidMessageDateException | MessageContentFetchingException $e) { |
|
250 | 250 | $this->setError($uid, $e); |
251 | 251 | } |
252 | 252 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $key = $message->getMessageId(); |
279 | 279 | break; |
280 | 280 | } |
281 | - return (string)$key; |
|
281 | + return (string) $key; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $extensions = $raw_messages["extensions"][$uid] ?? []; |
327 | 327 | |
328 | 328 | $message = $this->make($uid, $msglist, $header, $content, $flag); |
329 | - foreach($extensions as $key => $extension) { |
|
329 | + foreach ($extensions as $key => $extension) { |
|
330 | 330 | $message->getHeader()->set($key, $extension); |
331 | 331 | } |
332 | 332 | if ($message !== null) { |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | $uids = $connection->getUid(); |
479 | 479 | $available_messages = new Collection(); |
480 | 480 | if (is_array($uids)) { |
481 | - foreach ($uids as $id){ |
|
481 | + foreach ($uids as $id) { |
|
482 | 482 | if ($closure($id)) { |
483 | 483 | $available_messages->push($id); |
484 | 484 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | * @return int|null |
69 | 69 | */ |
70 | 70 | public function total($total = null): ?int { |
71 | - if($total === null) { |
|
71 | + if ($total === null) { |
|
72 | 72 | return $this->total; |
73 | 73 | } |
74 | 74 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function __construct(object $parent) { |
42 | 42 | $this->parent = $parent; |
43 | 43 | |
44 | - if(method_exists($this->parent, 'getAttributes')){ |
|
44 | + if (method_exists($this->parent, 'getAttributes')) { |
|
45 | 45 | $this->attributes = array_merge($this->attributes, $this->parent->getAttributes()); |
46 | 46 | } |
47 | 47 | |
@@ -62,17 +62,17 @@ discard block |
||
62 | 62 | * @throws MethodNotFoundException |
63 | 63 | */ |
64 | 64 | public function __call(string $method, array $arguments) { |
65 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
65 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
66 | 66 | $name = Str::snake(substr($method, 3)); |
67 | 67 | |
68 | - if(isset($this->attributes[$name])) { |
|
68 | + if (isset($this->attributes[$name])) { |
|
69 | 69 | return $this->attributes[$name]; |
70 | 70 | } |
71 | 71 | |
72 | 72 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
73 | 73 | $name = Str::snake(substr($method, 3)); |
74 | 74 | |
75 | - if(isset($this->attributes[$name])) { |
|
75 | + if (isset($this->attributes[$name])) { |
|
76 | 76 | $this->attributes[$name] = array_pop($arguments); |
77 | 77 | |
78 | 78 | return $this->attributes[$name]; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | } |
82 | 82 | |
83 | - if(method_exists($this->parent, $method) === true){ |
|
83 | + if (method_exists($this->parent, $method) === true) { |
|
84 | 84 | return call_user_func_array([$this->parent, $method], $arguments); |
85 | 85 | } |
86 | 86 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return mixed|null |
108 | 108 | */ |
109 | 109 | public function __get($name) { |
110 | - if(isset($this->attributes[$name])) { |
|
110 | + if (isset($this->attributes[$name])) { |
|
111 | 111 | return $this->attributes[$name]; |
112 | 112 | } |
113 | 113 |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return null |
32 | 32 | */ |
33 | - public function getHtmlBody(){ |
|
33 | + public function getHtmlBody() { |
|
34 | 34 | $bodies = $this->parent->getBodies(); |
35 | 35 | if (!isset($bodies['html'])) { |
36 | 36 | return null; |
37 | 37 | } |
38 | 38 | |
39 | - if(is_object($bodies['html']) && property_exists($bodies['html'], 'content')) { |
|
39 | + if (is_object($bodies['html']) && property_exists($bodies['html'], 'content')) { |
|
40 | 40 | return $bodies['html']->content; |
41 | 41 | } |
42 | 42 | return $bodies['html']; |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function getCustomHTMLBody($callback = false): ?string { |
52 | 52 | $body = $this->getHtmlBody(); |
53 | - if($body === null) return null; |
|
53 | + if ($body === null) return null; |
|
54 | 54 | |
55 | 55 | if ($callback !== false) { |
56 | 56 | $aAttachment = $this->parent->getAttachments(); |
57 | 57 | $aAttachment->each(function($oAttachment) use(&$body, $callback): void { |
58 | 58 | /** @var Attachment $oAttachment */ |
59 | - if(is_callable($callback)) { |
|
59 | + if (is_callable($callback)) { |
|
60 | 60 | $body = $callback($body, $oAttachment); |
61 | - }elseif(is_string($callback)) { |
|
61 | + }elseif (is_string($callback)) { |
|
62 | 62 | call_user_func($callback, [$body, $oAttachment]); |
63 | 63 | } |
64 | 64 | }); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @return string|null |
75 | 75 | */ |
76 | 76 | public function getHTMLBodyWithEmbeddedBase64Images(): ?string { |
77 | - return $this->getCustomHTMLBody(function($body, $oAttachment){ |
|
77 | + return $this->getCustomHTMLBody(function($body, $oAttachment) { |
|
78 | 78 | /** @var Attachment $oAttachment */ |
79 | 79 | if ($oAttachment->id) { |
80 | 80 | $body = str_replace('cid:'.$oAttachment->id, 'data:'.$oAttachment->getContentType().';base64, '.base64_encode($oAttachment->getContent()), $body); |
@@ -50,7 +50,9 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function getCustomHTMLBody($callback = false): ?string { |
52 | 52 | $body = $this->getHtmlBody(); |
53 | - if($body === null) return null; |
|
53 | + if($body === null) { |
|
54 | + return null; |
|
55 | + } |
|
54 | 56 | |
55 | 57 | if ($callback !== false) { |
56 | 58 | $aAttachment = $this->parent->getAttachments(); |
@@ -58,7 +60,7 @@ discard block |
||
58 | 60 | /** @var Attachment $oAttachment */ |
59 | 61 | if(is_callable($callback)) { |
60 | 62 | $body = $callback($body, $oAttachment); |
61 | - }elseif(is_string($callback)) { |
|
63 | + } elseif(is_string($callback)) { |
|
62 | 64 | call_user_func($callback, [$body, $oAttachment]); |
63 | 65 | } |
64 | 66 | }); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | $this->setDelimiter($delimiter); |
121 | 121 | $this->path = $folder_name; |
122 | - $this->full_name = $this->decodeName($folder_name); |
|
122 | + $this->full_name = $this->decodeName($folder_name); |
|
123 | 123 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
124 | 124 | |
125 | 125 | $this->parseAttributes($attributes); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | public function move(string $new_name, bool $expunge = true): bool { |
231 | 231 | $this->client->checkConnection(); |
232 | 232 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
233 | - if($expunge) $this->client->expunge(); |
|
233 | + if ($expunge) $this->client->expunge(); |
|
234 | 234 | |
235 | 235 | $folder = $this->client->getFolder($new_name); |
236 | 236 | $event = $this->getEvent("folder", "moved"); |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * date string that conforms to the rfc2060 specifications for a date_time value or be a Carbon object. |
274 | 274 | */ |
275 | 275 | |
276 | - if ($internal_date instanceof Carbon){ |
|
276 | + if ($internal_date instanceof Carbon) { |
|
277 | 277 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
278 | 278 | } |
279 | 279 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | */ |
307 | 307 | public function delete(bool $expunge = true): bool { |
308 | 308 | $status = $this->client->getConnection()->deleteFolder($this->path); |
309 | - if($expunge) $this->client->expunge(); |
|
309 | + if ($expunge) $this->client->expunge(); |
|
310 | 310 | |
311 | 311 | $event = $this->getEvent("folder", "deleted"); |
312 | 312 | $event::dispatch($this); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $line = $connection->nextLine(); |
373 | 373 | if (($pos = strpos($line, "EXISTS")) !== false) { |
374 | - $msgn = (int) substr($line, 2, $pos -2); |
|
374 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
375 | 375 | $connection->done(); |
376 | 376 | |
377 | 377 | $this->client->openFolder($this->path, true); |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | |
385 | 385 | $connection->idle(); |
386 | 386 | } |
387 | - }catch (Exceptions\RuntimeException $e) { |
|
388 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
387 | + } catch (Exceptions\RuntimeException $e) { |
|
388 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
389 | 389 | throw $e; |
390 | 390 | } |
391 | 391 | if ($auto_reconnect === true) { |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @param mixed $delimiter |
436 | 436 | */ |
437 | 437 | public function setDelimiter(string $delimiter): void { |
438 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
438 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
439 | 439 | $delimiter = ClientManager::get('options.delimiter', '/'); |
440 | 440 | } |
441 | 441 |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $this->part_number = $part->part_number; |
95 | 95 | |
96 | 96 | $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask(); |
97 | - if($default_mask != null) { |
|
97 | + if ($default_mask != null) { |
|
98 | 98 | $this->mask = $default_mask; |
99 | 99 | } |
100 | 100 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | public function __call(string $method, array $arguments) { |
114 | 114 | if (strtolower(substr($method, 0, 3)) === 'get') { |
115 | 115 | $name = Str::snake(substr($method, 3)); |
116 | - if(isset($this->attributes[$name])) { |
|
116 | + if (isset($this->attributes[$name])) { |
|
117 | 117 | return $this->attributes[$name]; |
118 | 118 | } |
119 | 119 | return null; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return mixed|null |
148 | 148 | */ |
149 | 149 | public function __get($name) { |
150 | - if(isset($this->attributes[$name])) { |
|
150 | + if (isset($this->attributes[$name])) { |
|
151 | 151 | return $this->attributes[$name]; |
152 | 152 | } |
153 | 153 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) { |
218 | 218 | if ($this->part->ifdescription) { |
219 | 219 | $this->setName($this->part->description); |
220 | - } else { |
|
220 | + }else { |
|
221 | 221 | $this->setName($this->part->subtype); |
222 | 222 | } |
223 | 223 | } |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | public function setName($name): void { |
244 | 244 | $decoder = $this->config['decoder']['attachment']; |
245 | 245 | if ($name !== null) { |
246 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
246 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
247 | 247 | $this->name = \imap_utf8($name); |
248 | - }else{ |
|
248 | + }else { |
|
249 | 249 | $this->name = mb_decode_mimeheader($name); |
250 | 250 | } |
251 | 251 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return string|false |
258 | 258 | */ |
259 | - public function getMimeType(){ |
|
259 | + public function getMimeType() { |
|
260 | 260 | return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE); |
261 | 261 | } |
262 | 262 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public function getExtension(): ?string{ |
269 | 269 | $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser"; |
270 | - if (class_exists($deprecated_guesser) !== false){ |
|
270 | + if (class_exists($deprecated_guesser) !== false) { |
|
271 | 271 | /** @var \Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser $deprecated_guesser */ |
272 | 272 | return $deprecated_guesser::getInstance()->guess($this->getMimeType()); |
273 | 273 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @return $this |
301 | 301 | */ |
302 | 302 | public function setMask(string $mask): self { |
303 | - if(class_exists($mask)){ |
|
303 | + if (class_exists($mask)) { |
|
304 | 304 | $this->mask = $mask; |
305 | 305 | } |
306 | 306 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public function mask($mask = null): object { |
327 | 327 | $mask ??= $this->mask; |
328 | - if(class_exists($mask)){ |
|
328 | + if (class_exists($mask)) { |
|
329 | 329 | return new $mask($this); |
330 | 330 | } |
331 | 331 |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $this->setName($filename); |
211 | 211 | } elseif (($name = $this->part->name) !== null) { |
212 | 212 | $this->setName($name); |
213 | - }else { |
|
213 | + } else { |
|
214 | 214 | $this->setName("undefined"); |
215 | 215 | } |
216 | 216 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | if ($name !== null) { |
246 | 246 | if($decoder === 'utf-8' && extension_loaded('imap')) { |
247 | 247 | $this->name = \imap_utf8($name); |
248 | - }else{ |
|
248 | + } else{ |
|
249 | 249 | $this->name = mb_decode_mimeheader($name); |
250 | 250 | } |
251 | 251 | } |
@@ -33,11 +33,11 @@ |
||
33 | 33 | * @param object $object |
34 | 34 | */ |
35 | 35 | public function __construct($object) { |
36 | - if (property_exists($object, "personal")){ $this->personal = $object->personal; } |
|
37 | - if (property_exists($object, "mailbox")){ $this->mailbox = $object->mailbox; } |
|
38 | - if (property_exists($object, "host")){ $this->host = $object->host; } |
|
39 | - if (property_exists($object, "mail")){ $this->mail = $object->mail; } |
|
40 | - if (property_exists($object, "full")){ $this->full = $object->full; } |
|
36 | + if (property_exists($object, "personal")) { $this->personal = $object->personal; } |
|
37 | + if (property_exists($object, "mailbox")) { $this->mailbox = $object->mailbox; } |
|
38 | + if (property_exists($object, "host")) { $this->host = $object->host; } |
|
39 | + if (property_exists($object, "mail")) { $this->mail = $object->mail; } |
|
40 | + if (property_exists($object, "full")) { $this->full = $object->full; } |
|
41 | 41 | } |
42 | 42 | |
43 | 43 |