@@ -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 | $valid_disposition = in_array(strtolower($this->disposition), ClientManager::get('options.dispositions')); |
303 | 303 | |
304 | 304 | if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition))) && !$valid_disposition) { |
@@ -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 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) { |
230 | 230 | if ($this->part->ifdescription) { |
231 | 231 | $this->setName($this->part->description); |
232 | - } else { |
|
232 | + }else { |
|
233 | 233 | $this->setName($this->part->subtype); |
234 | 234 | } |
235 | 235 | } |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | public function setName($name) { |
256 | 256 | $decoder = $this->config['decoder']['attachment']; |
257 | 257 | if ($name !== null) { |
258 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
258 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
259 | 259 | $this->name = \imap_utf8($name); |
260 | - }else{ |
|
260 | + }else { |
|
261 | 261 | $this->name = mb_decode_mimeheader($name); |
262 | 262 | } |
263 | 263 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return string|null |
270 | 270 | */ |
271 | - public function getMimeType(){ |
|
271 | + public function getMimeType() { |
|
272 | 272 | return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE); |
273 | 273 | } |
274 | 274 | |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return string|null |
279 | 279 | */ |
280 | - public function getExtension(){ |
|
280 | + public function getExtension() { |
|
281 | 281 | $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser"; |
282 | - if (class_exists($deprecated_guesser) !== false){ |
|
282 | + if (class_exists($deprecated_guesser) !== false) { |
|
283 | 283 | return $deprecated_guesser::getInstance()->guess($this->getMimeType()); |
284 | 284 | } |
285 | 285 | $guesser = "\Symfony\Component\Mime\MimeTypes"; |
@@ -292,14 +292,14 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @return array |
294 | 294 | */ |
295 | - public function getAttributes(){ |
|
295 | + public function getAttributes() { |
|
296 | 296 | return $this->attributes; |
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
300 | 300 | * @return Message |
301 | 301 | */ |
302 | - public function getMessage(){ |
|
302 | + public function getMessage() { |
|
303 | 303 | return $this->oMessage; |
304 | 304 | } |
305 | 305 | |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @return $this |
311 | 311 | */ |
312 | - public function setMask($mask){ |
|
313 | - if(class_exists($mask)){ |
|
312 | + public function setMask($mask) { |
|
313 | + if (class_exists($mask)) { |
|
314 | 314 | $this->mask = $mask; |
315 | 315 | } |
316 | 316 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @return string |
324 | 324 | */ |
325 | - public function getMask(){ |
|
325 | + public function getMask() { |
|
326 | 326 | return $this->mask; |
327 | 327 | } |
328 | 328 | |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | * @return mixed |
334 | 334 | * @throws MaskNotFoundException |
335 | 335 | */ |
336 | - public function mask($mask = null){ |
|
336 | + public function mask($mask = null) { |
|
337 | 337 | $mask = $mask !== null ? $mask : $this->mask; |
338 | - if(class_exists($mask)){ |
|
338 | + if (class_exists($mask)) { |
|
339 | 339 | return new $mask($this); |
340 | 340 | } |
341 | 341 |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | return null; |
131 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
131 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
132 | 132 | $name = Str::snake(substr($method, 3)); |
133 | 133 | |
134 | 134 | $this->attributes[$name] = array_pop($arguments); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $this->setName($filename); |
223 | 223 | } elseif (($name = $this->part->name) !== null) { |
224 | 224 | $this->setName($name); |
225 | - }else { |
|
225 | + } else { |
|
226 | 226 | $this->setName("undefined"); |
227 | 227 | } |
228 | 228 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | if ($name !== null) { |
258 | 258 | if($decoder === 'utf-8' && extension_loaded('imap')) { |
259 | 259 | $this->name = \imap_utf8($name); |
260 | - }else{ |
|
260 | + } else{ |
|
261 | 261 | $this->name = mb_decode_mimeheader($name); |
262 | 262 | } |
263 | 263 | } |
@@ -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 | ) { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | if (ClientManager::get('options.fetch_order') === 'desc') { |
90 | 90 | $this->fetch_order = 'desc'; |
91 | - } else { |
|
91 | + }else { |
|
92 | 92 | $this->fetch_order = 'asc'; |
93 | 93 | } |
94 | 94 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | break; |
119 | 119 | } |
120 | 120 | |
121 | - return (string)$value; |
|
121 | + return (string) $value; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | $raw_flag = isset($raw_flags[$uid]) ? $raw_flags[$uid] : []; |
246 | 246 | |
247 | 247 | $message = Message::make($uid, $msglist, $this->getClient(), $raw_header, $raw_content, $raw_flag, $this->getFetchOptions(), $this->sequence); |
248 | - switch ($message_key){ |
|
248 | + switch ($message_key) { |
|
249 | 249 | case 'number': |
250 | 250 | $key = $message->getMessageNo(); |
251 | 251 | break; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | return $messages; |
269 | 269 | } catch (\Exception $e) { |
270 | - throw new GetMessagesFailedException($e->getMessage(),0, $e); |
|
270 | + throw new GetMessagesFailedException($e->getMessage(), 0, $e); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
287 | 287 | * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException |
288 | 288 | */ |
289 | - public function getMessage($uid, $msglist = null, $sequence = null){ |
|
289 | + public function getMessage($uid, $msglist = null, $sequence = null) { |
|
290 | 290 | return new Message($uid, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags(), $sequence ? $sequence : $this->sequence); |
291 | 291 | } |
292 | 292 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
305 | 305 | * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException |
306 | 306 | */ |
307 | - public function getMessageByMsgn($msgn, $msglist = null){ |
|
307 | + public function getMessageByMsgn($msgn, $msglist = null) { |
|
308 | 308 | return $this->getMessage($msgn, $msglist, IMAP::ST_MSGN); |
309 | 309 | } |
310 | 310 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
322 | 322 | * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException |
323 | 323 | */ |
324 | - public function getMessageByUid($uid){ |
|
324 | + public function getMessageByUid($uid) { |
|
325 | 325 | return $this->getMessage($uid, null, IMAP::ST_UID); |
326 | 326 | } |
327 | 327 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @return LengthAwarePaginator |
335 | 335 | * @throws GetMessagesFailedException |
336 | 336 | */ |
337 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
337 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
338 | 338 | if ( |
339 | 339 | $page === null |
340 | 340 | && isset($_GET[$page_name]) |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | $this->query->each(function($statement) use(&$query) { |
361 | 361 | if (count($statement) == 1) { |
362 | 362 | $query .= $statement[0]; |
363 | - } else { |
|
364 | - if($statement[1] === null){ |
|
363 | + }else { |
|
364 | + if ($statement[1] === null) { |
|
365 | 365 | $query .= $statement[0]; |
366 | - }else{ |
|
366 | + }else { |
|
367 | 367 | $query .= $statement[0].' "'.$statement[1].'"'; |
368 | 368 | } |
369 | 369 | } |
@@ -84,7 +84,9 @@ discard block |
||
84 | 84 | $this->setClient($client); |
85 | 85 | |
86 | 86 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
87 | - if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
87 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
88 | + $this->leaveUnread(); |
|
89 | + } |
|
88 | 90 | |
89 | 91 | if (ClientManager::get('options.fetch_order') === 'desc') { |
90 | 92 | $this->fetch_order = 'desc'; |
@@ -129,7 +131,9 @@ discard block |
||
129 | 131 | * @throws MessageSearchValidationException |
130 | 132 | */ |
131 | 133 | protected function parse_date($date) { |
132 | - if ($date instanceof Carbon) return $date; |
|
134 | + if ($date instanceof Carbon) { |
|
135 | + return $date; |
|
136 | + } |
|
133 | 137 | |
134 | 138 | try { |
135 | 139 | $date = Carbon::parse($date); |
@@ -363,7 +367,7 @@ discard block |
||
363 | 367 | } else { |
364 | 368 | if($statement[1] === null){ |
365 | 369 | $query .= $statement[0]; |
366 | - }else{ |
|
370 | + } else{ |
|
367 | 371 | $query .= $statement[0].' "'.$statement[1].'"'; |
368 | 372 | } |
369 | 373 | } |
@@ -393,7 +397,9 @@ discard block |
||
393 | 397 | * @return $this |
394 | 398 | */ |
395 | 399 | public function limit($limit, $page = 1) { |
396 | - if ($page >= 1) $this->page = $page; |
|
400 | + if ($page >= 1) { |
|
401 | + $this->page = $page; |
|
402 | + } |
|
397 | 403 | $this->limit = $limit; |
398 | 404 | |
399 | 405 | return $this; |
@@ -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 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $value = $this->default_account_config[$key]; |
206 | 206 | if(isset($config[$key])) { |
207 | 207 | $value = $config[$key]; |
208 | - }elseif(isset($default_config[$key])) { |
|
208 | + } elseif(isset($default_config[$key])) { |
|
209 | 209 | $value = $default_config[$key]; |
210 | 210 | } |
211 | 211 | $this->$key = $value; |
@@ -239,39 +239,39 @@ discard block |
||
239 | 239 | if(isset($config['masks']['message'])) { |
240 | 240 | if(class_exists($config['masks']['message'])) { |
241 | 241 | $this->default_message_mask = $config['masks']['message']; |
242 | - }else{ |
|
242 | + } else{ |
|
243 | 243 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
244 | 244 | } |
245 | - }else{ |
|
245 | + } else{ |
|
246 | 246 | if(class_exists($default_config['message'])) { |
247 | 247 | $this->default_message_mask = $default_config['message']; |
248 | - }else{ |
|
248 | + } else{ |
|
249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
250 | 250 | } |
251 | 251 | } |
252 | 252 | if(isset($config['masks']['attachment'])) { |
253 | 253 | if(class_exists($config['masks']['attachment'])) { |
254 | 254 | $this->default_message_mask = $config['masks']['attachment']; |
255 | - }else{ |
|
255 | + } else{ |
|
256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
257 | 257 | } |
258 | - }else{ |
|
258 | + } else{ |
|
259 | 259 | if(class_exists($default_config['attachment'])) { |
260 | 260 | $this->default_message_mask = $default_config['attachment']; |
261 | - }else{ |
|
261 | + } else{ |
|
262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
263 | 263 | } |
264 | 264 | } |
265 | - }else{ |
|
265 | + } else{ |
|
266 | 266 | if(class_exists($default_config['message'])) { |
267 | 267 | $this->default_message_mask = $default_config['message']; |
268 | - }else{ |
|
268 | + } else{ |
|
269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
270 | 270 | } |
271 | 271 | |
272 | 272 | if(class_exists($default_config['attachment'])) { |
273 | 273 | $this->default_message_mask = $default_config['attachment']; |
274 | - }else{ |
|
274 | + } else{ |
|
275 | 275 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
276 | 276 | } |
277 | 277 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
336 | 336 | $this->connection->setConnectionTimeout($this->timeout); |
337 | 337 | $this->connection->setProxy($this->proxy); |
338 | - }else{ |
|
338 | + } else{ |
|
339 | 339 | if (extension_loaded('imap') === false) { |
340 | 340 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
341 | 341 | } |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } |
474 | 474 | |
475 | 475 | return $folders; |
476 | - }else{ |
|
476 | + } else{ |
|
477 | 477 | throw new FolderFetchingException("failed to fetch any folders"); |
478 | 478 | } |
479 | 479 | } |
@@ -511,7 +511,9 @@ discard block |
||
511 | 511 | $this->checkConnection(); |
512 | 512 | $status = $this->connection->createFolder($folder); |
513 | 513 | |
514 | - if($expunge) $this->expunge(); |
|
514 | + if($expunge) { |
|
515 | + $this->expunge(); |
|
516 | + } |
|
515 | 517 | |
516 | 518 | $folder = $this->getFolder($folder); |
517 | 519 | if($status && $folder) { |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | * @param array $config |
204 | 204 | * @param array $default_config |
205 | 205 | */ |
206 | - private function setAccountConfig($key, $config, $default_config){ |
|
206 | + private function setAccountConfig($key, $config, $default_config) { |
|
207 | 207 | $value = $this->default_account_config[$key]; |
208 | - if(isset($config[$key])) { |
|
208 | + if (isset($config[$key])) { |
|
209 | 209 | $value = $config[$key]; |
210 | - }elseif(isset($default_config[$key])) { |
|
210 | + }elseif (isset($default_config[$key])) { |
|
211 | 211 | $value = $default_config[$key]; |
212 | 212 | } |
213 | 213 | $this->$key = $value; |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | */ |
220 | 220 | protected function setEventsFromConfig($config) { |
221 | 221 | $this->events = ClientManager::get("events"); |
222 | - if(isset($config['events'])){ |
|
223 | - if(isset($config['events'])) { |
|
224 | - foreach($config['events'] as $section => $events) { |
|
222 | + if (isset($config['events'])) { |
|
223 | + if (isset($config['events'])) { |
|
224 | + foreach ($config['events'] as $section => $events) { |
|
225 | 225 | $this->events[$section] = array_merge($this->events[$section], $events); |
226 | 226 | } |
227 | 227 | } |
@@ -235,45 +235,45 @@ discard block |
||
235 | 235 | * @throws MaskNotFoundException |
236 | 236 | */ |
237 | 237 | protected function setMaskFromConfig($config) { |
238 | - $default_config = ClientManager::get("masks"); |
|
238 | + $default_config = ClientManager::get("masks"); |
|
239 | 239 | |
240 | - if(isset($config['masks'])){ |
|
241 | - if(isset($config['masks']['message'])) { |
|
242 | - if(class_exists($config['masks']['message'])) { |
|
240 | + if (isset($config['masks'])) { |
|
241 | + if (isset($config['masks']['message'])) { |
|
242 | + if (class_exists($config['masks']['message'])) { |
|
243 | 243 | $this->default_message_mask = $config['masks']['message']; |
244 | - }else{ |
|
244 | + }else { |
|
245 | 245 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
246 | 246 | } |
247 | - }else{ |
|
248 | - if(class_exists($default_config['message'])) { |
|
247 | + }else { |
|
248 | + if (class_exists($default_config['message'])) { |
|
249 | 249 | $this->default_message_mask = $default_config['message']; |
250 | - }else{ |
|
250 | + }else { |
|
251 | 251 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
252 | 252 | } |
253 | 253 | } |
254 | - if(isset($config['masks']['attachment'])) { |
|
255 | - if(class_exists($config['masks']['attachment'])) { |
|
254 | + if (isset($config['masks']['attachment'])) { |
|
255 | + if (class_exists($config['masks']['attachment'])) { |
|
256 | 256 | $this->default_message_mask = $config['masks']['attachment']; |
257 | - }else{ |
|
257 | + }else { |
|
258 | 258 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
259 | 259 | } |
260 | - }else{ |
|
261 | - if(class_exists($default_config['attachment'])) { |
|
260 | + }else { |
|
261 | + if (class_exists($default_config['attachment'])) { |
|
262 | 262 | $this->default_message_mask = $default_config['attachment']; |
263 | - }else{ |
|
263 | + }else { |
|
264 | 264 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
265 | 265 | } |
266 | 266 | } |
267 | - }else{ |
|
268 | - if(class_exists($default_config['message'])) { |
|
267 | + }else { |
|
268 | + if (class_exists($default_config['message'])) { |
|
269 | 269 | $this->default_message_mask = $default_config['message']; |
270 | - }else{ |
|
270 | + }else { |
|
271 | 271 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
272 | 272 | } |
273 | 273 | |
274 | - if(class_exists($default_config['attachment'])) { |
|
274 | + if (class_exists($default_config['attachment'])) { |
|
275 | 275 | $this->default_message_mask = $default_config['attachment']; |
276 | - }else{ |
|
276 | + }else { |
|
277 | 277 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
278 | 278 | } |
279 | 279 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
338 | 338 | $this->connection->setConnectionTimeout($this->timeout); |
339 | 339 | $this->connection->setProxy($this->proxy); |
340 | - }else{ |
|
340 | + }else { |
|
341 | 341 | if (extension_loaded('imap') === false) { |
342 | 342 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
343 | 343 | } |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
461 | 461 | $items = $this->connection->folders('', $pattern); |
462 | 462 | |
463 | - if(is_array($items)){ |
|
463 | + if (is_array($items)) { |
|
464 | 464 | foreach ($items as $folder_name => $item) { |
465 | 465 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
466 | 466 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | return $folders; |
478 | - }else{ |
|
478 | + }else { |
|
479 | 479 | throw new FolderFetchingException("failed to fetch any folders"); |
480 | 480 | } |
481 | 481 | } |
@@ -513,10 +513,10 @@ discard block |
||
513 | 513 | $this->checkConnection(); |
514 | 514 | $status = $this->connection->createFolder($folder); |
515 | 515 | |
516 | - if($expunge) $this->expunge(); |
|
516 | + if ($expunge) $this->expunge(); |
|
517 | 517 | |
518 | 518 | $folder = $this->getFolder($folder); |
519 | - if($status && $folder) { |
|
519 | + if ($status && $folder) { |
|
520 | 520 | $event = $this->getEvent("folder", "new"); |
521 | 521 | $event::dispatch($folder); |
522 | 522 | } |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @return Folder |
544 | 544 | */ |
545 | - public function getFolderPath(){ |
|
545 | + public function getFolderPath() { |
|
546 | 546 | return $this->active_folder; |
547 | 547 | } |
548 | 548 | |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * |
598 | 598 | * @return int |
599 | 599 | */ |
600 | - public function getTimeout(){ |
|
600 | + public function getTimeout() { |
|
601 | 601 | return $this->connection->getConnectionTimeout(); |
602 | 602 | } |
603 | 603 | |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | * |
607 | 607 | * @return string |
608 | 608 | */ |
609 | - public function getDefaultMessageMask(){ |
|
609 | + public function getDefaultMessageMask() { |
|
610 | 610 | return $this->default_message_mask; |
611 | 611 | } |
612 | 612 | |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * |
617 | 617 | * @return array |
618 | 618 | */ |
619 | - public function getDefaultEvents($section){ |
|
619 | + public function getDefaultEvents($section) { |
|
620 | 620 | return $this->events[$section]; |
621 | 621 | } |
622 | 622 | |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * @throws MaskNotFoundException |
629 | 629 | */ |
630 | 630 | public function setDefaultMessageMask($mask) { |
631 | - if(class_exists($mask)) { |
|
631 | + if (class_exists($mask)) { |
|
632 | 632 | $this->default_message_mask = $mask; |
633 | 633 | |
634 | 634 | return $this; |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * |
643 | 643 | * @return string |
644 | 644 | */ |
645 | - public function getDefaultAttachmentMask(){ |
|
645 | + public function getDefaultAttachmentMask() { |
|
646 | 646 | return $this->default_attachment_mask; |
647 | 647 | } |
648 | 648 | |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | * @throws MaskNotFoundException |
655 | 655 | */ |
656 | 656 | public function setDefaultAttachmentMask($mask) { |
657 | - if(class_exists($mask)) { |
|
657 | + if (class_exists($mask)) { |
|
658 | 658 | $this->default_attachment_mask = $mask; |
659 | 659 | |
660 | 660 | return $this; |
@@ -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 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | $this->setDelimiter($delimiter); |
124 | 124 | $this->path = $folder_name; |
125 | - $this->full_name = $this->decodeName($folder_name); |
|
125 | + $this->full_name = $this->decodeName($folder_name); |
|
126 | 126 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
127 | 127 | |
128 | 128 | $this->parseAttributes($attributes); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @throws Exceptions\ConnectionFailedException |
137 | 137 | * @throws Exceptions\RuntimeException |
138 | 138 | */ |
139 | - public function query($charset = 'UTF-8'){ |
|
139 | + public function query($charset = 'UTF-8') { |
|
140 | 140 | $this->getClient()->checkConnection(); |
141 | 141 | $this->getClient()->openFolder($this->path); |
142 | 142 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @throws Exceptions\ConnectionFailedException |
149 | 149 | * @throws Exceptions\RuntimeException |
150 | 150 | */ |
151 | - public function search($charset = 'UTF-8'){ |
|
151 | + public function search($charset = 'UTF-8') { |
|
152 | 152 | return $this->query($charset); |
153 | 153 | } |
154 | 154 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @throws Exceptions\ConnectionFailedException |
158 | 158 | * @throws Exceptions\RuntimeException |
159 | 159 | */ |
160 | - public function messages($charset = 'UTF-8'){ |
|
160 | + public function messages($charset = 'UTF-8') { |
|
161 | 161 | return $this->query($charset); |
162 | 162 | } |
163 | 163 | |
@@ -232,7 +232,7 @@ 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) $this->client->expunge(); |
|
236 | 236 | |
237 | 237 | $folder = $this->client->getFolder($new_name); |
238 | 238 | $event = $this->getEvent("folder", "moved"); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @throws Exceptions\InvalidMessageDateException |
251 | 251 | * @throws Exceptions\RuntimeException |
252 | 252 | */ |
253 | - public function overview($sequence = null){ |
|
253 | + public function overview($sequence = null) { |
|
254 | 254 | $this->client->openFolder($this->path); |
255 | 255 | $sequence = $sequence === null ? "1:*" : $sequence; |
256 | 256 | $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | |
277 | 277 | if ($internal_date != null) { |
278 | - if ($internal_date instanceof Carbon){ |
|
278 | + if ($internal_date instanceof Carbon) { |
|
279 | 279 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
280 | 280 | } |
281 | 281 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function delete($expunge = true) { |
311 | 311 | $status = $this->client->getConnection()->deleteFolder($this->path); |
312 | - if($expunge) $this->client->expunge(); |
|
312 | + if ($expunge) $this->client->expunge(); |
|
313 | 313 | |
314 | 314 | $event = $this->getEvent("folder", "deleted"); |
315 | 315 | $event::dispatch($this); |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | try { |
370 | 370 | $line = $connection->nextLine(); |
371 | 371 | if (($pos = strpos($line, "EXISTS")) !== false) { |
372 | - $msgn = (int) substr($line, 2, $pos -2); |
|
372 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
373 | 373 | $connection->done(); |
374 | 374 | |
375 | 375 | $this->client->openFolder($this->path, true); |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | |
383 | 383 | $connection->idle(); |
384 | 384 | } |
385 | - }catch (Exceptions\RuntimeException $e) { |
|
386 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
385 | + } catch (Exceptions\RuntimeException $e) { |
|
386 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
387 | 387 | throw $e; |
388 | 388 | } |
389 | 389 | if ($auto_reconnect === true) { |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | * Set the delimiter |
429 | 429 | * @param $delimiter |
430 | 430 | */ |
431 | - public function setDelimiter($delimiter){ |
|
432 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
431 | + public function setDelimiter($delimiter) { |
|
432 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
433 | 433 | $delimiter = ClientManager::get('options.delimiter', '/'); |
434 | 434 | } |
435 | 435 |
@@ -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 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - public function toString(){ |
|
57 | + public function toString() { |
|
58 | 58 | return $this->__toString(); |
59 | 59 | } |
60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return array |
65 | 65 | */ |
66 | - public function __serialize(){ |
|
66 | + public function __serialize() { |
|
67 | 67 | return $this->values; |
68 | 68 | } |
69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - public function toArray(){ |
|
75 | + public function toArray() { |
|
76 | 76 | return $this->__serialize(); |
77 | 77 | } |
78 | 78 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | public function offsetSet($key, $value) { |
107 | 107 | if (is_null($key)) { |
108 | 108 | $this->values[] = $value; |
109 | - } else { |
|
109 | + }else { |
|
110 | 110 | $this->values[$key] = $value; |
111 | 111 | } |
112 | 112 | } |
@@ -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 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return Attribute |
193 | 193 | */ |
194 | - public function setName($name){ |
|
194 | + public function setName($name) { |
|
195 | 195 | $this->name = $name; |
196 | 196 | |
197 | 197 | return $this; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return string |
204 | 204 | */ |
205 | - public function getName(){ |
|
205 | + public function getName() { |
|
206 | 206 | return $this->name; |
207 | 207 | } |
208 | 208 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return array |
213 | 213 | */ |
214 | - public function get(){ |
|
214 | + public function get() { |
|
215 | 215 | return $this->values; |
216 | 216 | } |
217 | 217 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return array |
222 | 222 | */ |
223 | - public function all(){ |
|
223 | + public function all() { |
|
224 | 224 | return $this->get(); |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return mixed|null |
231 | 231 | */ |
232 | - public function first(){ |
|
232 | + public function first() { |
|
233 | 233 | if (count($this->values) > 0) { |
234 | 234 | return $this->values[0]; |
235 | 235 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return mixed|null |
243 | 243 | */ |
244 | - public function last(){ |
|
244 | + public function last() { |
|
245 | 245 | $cnt = count($this->values); |
246 | 246 | if ($cnt > 0) { |
247 | 247 | return $this->values[$cnt - 1]; |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @param object $object |
45 | 45 | */ |
46 | 46 | public function __construct($object) { |
47 | - if (property_exists($object, "personal")){ $this->personal = $object->personal; } |
|
48 | - if (property_exists($object, "mailbox")){ $this->mailbox = $object->mailbox; } |
|
49 | - if (property_exists($object, "host")){ $this->host = $object->host; } |
|
50 | - if (property_exists($object, "mail")){ $this->mail = $object->mail; } |
|
51 | - if (property_exists($object, "full")){ $this->full = $object->full; } |
|
47 | + if (property_exists($object, "personal")) { $this->personal = $object->personal; } |
|
48 | + if (property_exists($object, "mailbox")) { $this->mailbox = $object->mailbox; } |
|
49 | + if (property_exists($object, "host")) { $this->host = $object->host; } |
|
50 | + if (property_exists($object, "mail")) { $this->mail = $object->mail; } |
|
51 | + if (property_exists($object, "full")) { $this->full = $object->full; } |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - public function __serialize(){ |
|
69 | + public function __serialize() { |
|
70 | 70 | return [ |
71 | 71 | "personal" => $this->personal, |
72 | 72 | "mailbox" => $this->mailbox, |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return array |
83 | 83 | */ |
84 | - public function toArray(){ |
|
84 | + public function toArray() { |
|
85 | 85 | return $this->__serialize(); |
86 | 86 | } |
87 | 87 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - public function toString(){ |
|
93 | + public function toString() { |
|
94 | 94 | return $this->__toString(); |
95 | 95 | } |
96 | 96 | } |
97 | 97 | \ No newline at end of file |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @throws ConnectionFailedException |
85 | 85 | * @throws RuntimeException |
86 | 86 | */ |
87 | - protected function enableTls(){ |
|
87 | + protected function enableTls() { |
|
88 | 88 | $response = $this->requestAndResponse('STARTTLS'); |
89 | 89 | $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod()); |
90 | 90 | if (!$result) { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $stack = []; |
147 | 147 | |
148 | 148 | // replace any trailing <NL> including spaces with a single space |
149 | - $line = rtrim($line) . ' '; |
|
149 | + $line = rtrim($line).' '; |
|
150 | 150 | while (($pos = strpos($line, ' ')) !== false) { |
151 | 151 | $token = substr($line, 0, $pos); |
152 | 152 | if (!strlen($token)) { |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | if (strlen($token) > $chars) { |
177 | 177 | $line = substr($token, $chars); |
178 | 178 | $token = substr($token, 0, $chars); |
179 | - } else { |
|
179 | + }else { |
|
180 | 180 | $line .= $this->nextLine(); |
181 | 181 | } |
182 | 182 | $tokens[] = $token; |
183 | - $line = trim($line) . ' '; |
|
183 | + $line = trim($line).' '; |
|
184 | 184 | continue; |
185 | 185 | } |
186 | 186 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $line = $this->nextTaggedLine($tag); // get next tag |
231 | 231 | if (!$dontParse) { |
232 | 232 | $tokens = $this->decodeLine($line); |
233 | - } else { |
|
233 | + }else { |
|
234 | 234 | $tokens = $line; |
235 | 235 | } |
236 | 236 | if ($this->debug) echo "<< ".$line."\n"; |
@@ -280,27 +280,27 @@ discard block |
||
280 | 280 | public function sendRequest($command, $tokens = [], &$tag = null) { |
281 | 281 | if (!$tag) { |
282 | 282 | $this->noun++; |
283 | - $tag = 'TAG' . $this->noun; |
|
283 | + $tag = 'TAG'.$this->noun; |
|
284 | 284 | } |
285 | 285 | |
286 | - $line = $tag . ' ' . $command; |
|
286 | + $line = $tag.' '.$command; |
|
287 | 287 | |
288 | 288 | foreach ($tokens as $token) { |
289 | 289 | if (is_array($token)) { |
290 | - if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) { |
|
290 | + if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) { |
|
291 | 291 | throw new RuntimeException('failed to write - connection closed?'); |
292 | 292 | } |
293 | 293 | if (!$this->assumedNextLine('+ ')) { |
294 | 294 | throw new RuntimeException('failed to send literal string'); |
295 | 295 | } |
296 | 296 | $line = $token[1]; |
297 | - } else { |
|
298 | - $line .= ' ' . $token; |
|
297 | + }else { |
|
298 | + $line .= ' '.$token; |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | if ($this->debug) echo ">> ".$line."\n"; |
302 | 302 | |
303 | - if (fwrite($this->stream, $line . "\r\n") === false) { |
|
303 | + if (fwrite($this->stream, $line."\r\n") === false) { |
|
304 | 304 | throw new RuntimeException('failed to write - connection closed?'); |
305 | 305 | } |
306 | 306 | } |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | public function escapeString($string) { |
331 | 331 | if (func_num_args() < 2) { |
332 | 332 | if (strpos($string, "\n") !== false) { |
333 | - return ['{' . strlen($string) . '}', $string]; |
|
334 | - } else { |
|
335 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
333 | + return ['{'.strlen($string).'}', $string]; |
|
334 | + }else { |
|
335 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | $result = []; |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | } |
358 | 358 | $result[] = $this->escapeList($v); |
359 | 359 | } |
360 | - return '(' . implode(' ', $result) . ')'; |
|
360 | + return '('.implode(' ', $result).')'; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | error_log("got an extra server challenge: $response"); |
398 | 398 | // respond with an empty response. |
399 | 399 | $this->sendRequest(''); |
400 | - } else { |
|
400 | + }else { |
|
401 | 401 | if (preg_match('/^NO /i', $response) || |
402 | 402 | preg_match('/^BAD /i', $response)) { |
403 | 403 | error_log("got failure response: $response"); |
404 | 404 | return false; |
405 | - } else if (preg_match("/^OK /i", $response)) { |
|
405 | + }else if (preg_match("/^OK /i", $response)) { |
|
406 | 406 | return true; |
407 | 407 | } |
408 | 408 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return bool |
437 | 437 | */ |
438 | - public function connected(){ |
|
438 | + public function connected() { |
|
439 | 439 | return (boolean) $this->stream; |
440 | 440 | } |
441 | 441 | |
@@ -482,10 +482,10 @@ discard block |
||
482 | 482 | $result[strtolower($tokens[1])] = $tokens[0]; |
483 | 483 | break; |
484 | 484 | case '[UIDVALIDITY': |
485 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
485 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
486 | 486 | break; |
487 | 487 | case '[UIDNEXT': |
488 | - $result['uidnext'] = (int)$tokens[2]; |
|
488 | + $result['uidnext'] = (int) $tokens[2]; |
|
489 | 489 | break; |
490 | 490 | default: |
491 | 491 | // ignore |
@@ -539,17 +539,17 @@ discard block |
||
539 | 539 | if (is_array($from)) { |
540 | 540 | $set = implode(',', $from); |
541 | 541 | } elseif ($to === null) { |
542 | - $set = (int)$from; |
|
542 | + $set = (int) $from; |
|
543 | 543 | } elseif ($to === INF) { |
544 | - $set = (int)$from . ':*'; |
|
545 | - } else { |
|
546 | - $set = (int)$from . ':' . (int)$to; |
|
544 | + $set = (int) $from.':*'; |
|
545 | + }else { |
|
546 | + $set = (int) $from.':'.(int) $to; |
|
547 | 547 | } |
548 | 548 | |
549 | - $items = (array)$items; |
|
549 | + $items = (array) $items; |
|
550 | 550 | $itemList = $this->escapeList($items); |
551 | 551 | |
552 | - $this->sendRequest(($uid ? 'UID ' : '') . 'FETCH', [$set, $itemList], $tag); |
|
552 | + $this->sendRequest(($uid ? 'UID ' : '').'FETCH', [$set, $itemList], $tag); |
|
553 | 553 | |
554 | 554 | $result = []; |
555 | 555 | $tokens = null; // define $tokens variable before first use |
@@ -564,9 +564,9 @@ discard block |
||
564 | 564 | $count = count($tokens[2]); |
565 | 565 | if ($tokens[2][$count - 2] == 'UID') { |
566 | 566 | $uidKey = $count - 1; |
567 | - } else if ($tokens[2][0] == 'UID') { |
|
567 | + }else if ($tokens[2][0] == 'UID') { |
|
568 | 568 | $uidKey = 1; |
569 | - } else { |
|
569 | + }else { |
|
570 | 570 | $uidKey = array_search('UID', $tokens[2]) + 1; |
571 | 571 | } |
572 | 572 | } |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | $data = $tokens[2][1]; |
583 | 583 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
584 | 584 | $data = $tokens[2][3]; |
585 | - } else { |
|
585 | + }else { |
|
586 | 586 | // maybe the server send an other field we didn't wanted |
587 | 587 | $count = count($tokens[2]); |
588 | 588 | // we start with 2, because 0 was already checked |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | break; |
595 | 595 | } |
596 | 596 | } |
597 | - } else { |
|
597 | + }else { |
|
598 | 598 | $data = []; |
599 | 599 | while (key($tokens[2]) !== null) { |
600 | 600 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | } |
612 | 612 | if ($uid) { |
613 | 613 | $result[$tokens[2][$uidKey]] = $data; |
614 | - }else{ |
|
614 | + }else { |
|
615 | 615 | $result[$tokens[0]] = $data; |
616 | 616 | } |
617 | 617 | } |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | * @return array |
646 | 646 | * @throws RuntimeException |
647 | 647 | */ |
648 | - public function headers($uids, $rfc = "RFC822", $uid = false){ |
|
648 | + public function headers($uids, $rfc = "RFC822", $uid = false) { |
|
649 | 649 | return $this->fetch(["$rfc.HEADER"], $uids, null, $uid); |
650 | 650 | } |
651 | 651 | |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | * @return array |
658 | 658 | * @throws RuntimeException |
659 | 659 | */ |
660 | - public function flags($uids, $uid = false){ |
|
660 | + public function flags($uids, $uid = false) { |
|
661 | 661 | return $this->fetch(["FLAGS"], $uids, null, $uid); |
662 | 662 | } |
663 | 663 | |
@@ -742,23 +742,23 @@ discard block |
||
742 | 742 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) { |
743 | 743 | $item = 'FLAGS'; |
744 | 744 | if ($mode == '+' || $mode == '-') { |
745 | - $item = $mode . $item; |
|
745 | + $item = $mode.$item; |
|
746 | 746 | } |
747 | 747 | if ($silent) { |
748 | 748 | $item .= '.SILENT'; |
749 | 749 | } |
750 | 750 | |
751 | 751 | $flags = $this->escapeList($flags); |
752 | - $set = (int)$from; |
|
752 | + $set = (int) $from; |
|
753 | 753 | if ($to !== null) { |
754 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
754 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | $command = ($uid ? "UID " : "")."STORE"; |
758 | 758 | $result = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
759 | 759 | |
760 | 760 | if ($silent) { |
761 | - return (bool)$result; |
|
761 | + return (bool) $result; |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | $tokens = $result; |
@@ -809,9 +809,9 @@ discard block |
||
809 | 809 | * @throws RuntimeException |
810 | 810 | */ |
811 | 811 | public function copyMessage($folder, $from, $to = null, $uid = false) { |
812 | - $set = (int)$from; |
|
812 | + $set = (int) $from; |
|
813 | 813 | if ($to !== null) { |
814 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
814 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
815 | 815 | } |
816 | 816 | $command = ($uid ? "UID " : "")."COPY"; |
817 | 817 | |
@@ -830,9 +830,9 @@ discard block |
||
830 | 830 | * @throws RuntimeException |
831 | 831 | */ |
832 | 832 | public function moveMessage($folder, $from, $to = null, $uid = false) { |
833 | - $set = (int)$from; |
|
833 | + $set = (int) $from; |
|
834 | 834 | if ($to !== null) { |
835 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
835 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
836 | 836 | } |
837 | 837 | $command = ($uid ? "UID " : "")."MOVE"; |
838 | 838 | |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | $ids = []; |
1003 | 1003 | foreach ($uids as $msgn => $v) { |
1004 | 1004 | $id = $uid ? $v : $msgn; |
1005 | - if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){ |
|
1005 | + if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) { |
|
1006 | 1006 | $ids[] = $id; |
1007 | 1007 | } |
1008 | 1008 | } |
@@ -1016,14 +1016,14 @@ discard block |
||
1016 | 1016 | /** |
1017 | 1017 | * Enable the debug mode |
1018 | 1018 | */ |
1019 | - public function enableDebug(){ |
|
1019 | + public function enableDebug() { |
|
1020 | 1020 | $this->debug = true; |
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
1024 | 1024 | * Disable the debug mode |
1025 | 1025 | */ |
1026 | - public function disableDebug(){ |
|
1026 | + public function disableDebug() { |
|
1027 | 1027 | $this->debug = false; |
1028 | 1028 | } |
1029 | 1029 | } |
1030 | 1030 | \ No newline at end of file |
@@ -233,7 +233,9 @@ discard block |
||
233 | 233 | } else { |
234 | 234 | $tokens = $line; |
235 | 235 | } |
236 | - if ($this->debug) echo "<< ".$line."\n"; |
|
236 | + if ($this->debug) { |
|
237 | + echo "<< ".$line."\n"; |
|
238 | + } |
|
237 | 239 | |
238 | 240 | // if tag is wanted tag we might be at the end of a multiline response |
239 | 241 | return $tag == $wantedTag; |
@@ -298,7 +300,9 @@ discard block |
||
298 | 300 | $line .= ' ' . $token; |
299 | 301 | } |
300 | 302 | } |
301 | - if ($this->debug) echo ">> ".$line."\n"; |
|
303 | + if ($this->debug) { |
|
304 | + echo ">> ".$line."\n"; |
|
305 | + } |
|
302 | 306 | |
303 | 307 | if (fwrite($this->stream, $line . "\r\n") === false) { |
304 | 308 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -448,7 +452,9 @@ discard block |
||
448 | 452 | public function getCapabilities() { |
449 | 453 | $response = $this->requestAndResponse('CAPABILITY'); |
450 | 454 | |
451 | - if (!$response) return []; |
|
455 | + if (!$response) { |
|
456 | + return []; |
|
457 | + } |
|
452 | 458 | |
453 | 459 | $capabilities = []; |
454 | 460 | foreach ($response as $line) { |
@@ -605,13 +611,14 @@ discard block |
||
605 | 611 | // if we want only one message we can ignore everything else and just return |
606 | 612 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
607 | 613 | // we still need to read all lines |
608 | - while (!$this->readLine($tokens, $tag)) |
|
609 | - |
|
614 | + while (!$this->readLine($tokens, $tag)) { |
|
615 | + |
|
610 | 616 | return $data; |
617 | + } |
|
611 | 618 | } |
612 | 619 | if ($uid) { |
613 | 620 | $result[$tokens[2][$uidKey]] = $data; |
614 | - }else{ |
|
621 | + } else{ |
|
615 | 622 | $result[$tokens[0]] = $data; |
616 | 623 | } |
617 | 624 | } |