@@ -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, |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | public static function get(string $key, $default = null) { |
77 | 77 | $parts = explode('.', $key); |
78 | 78 | $value = null; |
79 | - foreach($parts as $part) { |
|
80 | - if($value === null) { |
|
81 | - if(isset(self::$config[$part])) { |
|
79 | + foreach ($parts as $part) { |
|
80 | + if ($value === null) { |
|
81 | + if (isset(self::$config[$part])) { |
|
82 | 82 | $value = self::$config[$part]; |
83 | - }else{ |
|
83 | + }else { |
|
84 | 84 | break; |
85 | 85 | } |
86 | - }else{ |
|
87 | - if(isset($value[$part])) { |
|
86 | + }else { |
|
87 | + if (isset($value[$part])) { |
|
88 | 88 | $value = $value[$part]; |
89 | - }else{ |
|
89 | + }else { |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function setConfig($config): ClientManager { |
177 | 177 | |
178 | - if(is_array($config) === false) { |
|
178 | + if (is_array($config) === false) { |
|
179 | 179 | $config = require $config; |
180 | 180 | } |
181 | 181 | |
@@ -185,17 +185,17 @@ discard block |
||
185 | 185 | $vendor_config = require $path; |
186 | 186 | $config = $this->array_merge_recursive_distinct($vendor_config, $config); |
187 | 187 | |
188 | - if(is_array($config)){ |
|
189 | - if(isset($config['default'])){ |
|
190 | - if(isset($config['accounts']) && $config['default'] != false){ |
|
188 | + if (is_array($config)) { |
|
189 | + if (isset($config['default'])) { |
|
190 | + if (isset($config['accounts']) && $config['default'] != false) { |
|
191 | 191 | |
192 | 192 | $default_config = $vendor_config['accounts']['default']; |
193 | - if(isset($config['accounts'][$config['default']])){ |
|
193 | + if (isset($config['accounts'][$config['default']])) { |
|
194 | 194 | $default_config = array_merge($default_config, $config['accounts'][$config['default']]); |
195 | 195 | } |
196 | 196 | |
197 | - if(is_array($config['accounts'])){ |
|
198 | - foreach($config['accounts'] as $account_key => $account){ |
|
197 | + if (is_array($config['accounts'])) { |
|
198 | + foreach ($config['accounts'] as $account_key => $account) { |
|
199 | 199 | $config['accounts'][$account_key] = array_merge($default_config, $account); |
200 | 200 | } |
201 | 201 | } |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | return array_keys($arr) !== range(0, count($arr) - 1); |
235 | 235 | }; |
236 | 236 | |
237 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
237 | + if (!is_array($base)) $base = empty($base) ? array() : array($base); |
|
238 | 238 | |
239 | - foreach($arrays as $append) { |
|
239 | + foreach ($arrays as $append) { |
|
240 | 240 | |
241 | - if(!is_array($append)) $append = array($append); |
|
241 | + if (!is_array($append)) $append = array($append); |
|
242 | 242 | |
243 | - foreach($append as $key => $value) { |
|
243 | + foreach ($append as $key => $value) { |
|
244 | 244 | |
245 | - if(!array_key_exists($key, $base) and !is_numeric($key)) { |
|
245 | + if (!array_key_exists($key, $base) and !is_numeric($key)) { |
|
246 | 246 | $base[$key] = $value; |
247 | 247 | continue; |
248 | 248 | } |
249 | 249 | |
250 | - if( |
|
250 | + if ( |
|
251 | 251 | ( |
252 | 252 | is_array($value) |
253 | 253 | && $isAssoc($value) |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | // else merging $baseConfig['dispositions'] = ['attachment', 'inline'] with $customConfig['dispositions'] = ['attachment'] |
262 | 262 | // results in $resultConfig['dispositions'] = ['attachment', 'inline'] |
263 | 263 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $value); |
264 | - } else if(is_numeric($key)) { |
|
265 | - if(!in_array($value, $base)) $base[] = $value; |
|
266 | - } else { |
|
264 | + }else if (is_numeric($key)) { |
|
265 | + if (!in_array($value, $base)) $base[] = $value; |
|
266 | + }else { |
|
267 | 267 | $base[$key] = $value; |
268 | 268 | } |
269 | 269 |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | if($value === null) { |
81 | 81 | if(isset(self::$config[$part])) { |
82 | 82 | $value = self::$config[$part]; |
83 | - }else{ |
|
83 | + } else{ |
|
84 | 84 | break; |
85 | 85 | } |
86 | - }else{ |
|
86 | + } else{ |
|
87 | 87 | if(isset($value[$part])) { |
88 | 88 | $value = $value[$part]; |
89 | - }else{ |
|
89 | + } else{ |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
@@ -230,15 +230,21 @@ discard block |
||
230 | 230 | |
231 | 231 | // From https://stackoverflow.com/a/173479 |
232 | 232 | $isAssoc = function(array $arr) { |
233 | - if (array() === $arr) return false; |
|
233 | + if (array() === $arr) { |
|
234 | + return false; |
|
235 | + } |
|
234 | 236 | return array_keys($arr) !== range(0, count($arr) - 1); |
235 | 237 | }; |
236 | 238 | |
237 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
239 | + if(!is_array($base)) { |
|
240 | + $base = empty($base) ? array() : array($base); |
|
241 | + } |
|
238 | 242 | |
239 | 243 | foreach($arrays as $append) { |
240 | 244 | |
241 | - if(!is_array($append)) $append = array($append); |
|
245 | + if(!is_array($append)) { |
|
246 | + $append = array($append); |
|
247 | + } |
|
242 | 248 | |
243 | 249 | foreach($append as $key => $value) { |
244 | 250 | |
@@ -262,7 +268,9 @@ discard block |
||
262 | 268 | // results in $resultConfig['dispositions'] = ['attachment', 'inline'] |
263 | 269 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $value); |
264 | 270 | } else if(is_numeric($key)) { |
265 | - if(!in_array($value, $base)) $base[] = $value; |
|
271 | + if(!in_array($value, $base)) { |
|
272 | + $base[] = $value; |
|
273 | + } |
|
266 | 274 | } else { |
267 | 275 | $base[$key] = $value; |
268 | 276 | } |
@@ -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)) { |
@@ -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; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public function offsetSet($offset, $value) { |
116 | 116 | if (is_null($offset)) { |
117 | 117 | $this->values[] = $value; |
118 | - } else { |
|
118 | + }else { |
|
119 | 119 | $this->values[$offset] = $value; |
120 | 120 | } |
121 | 121 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | if ($this->contains($value) === false) { |
189 | 189 | $this->values[] = $value; |
190 | 190 | } |
191 | - }else{ |
|
191 | + }else { |
|
192 | 192 | $this->values[] = $value; |
193 | 193 | } |
194 | 194 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return mixed|null |
239 | 239 | */ |
240 | - public function first(){ |
|
240 | + public function first() { |
|
241 | 241 | if ($this->offsetExists(0)) { |
242 | 242 | return $this->values[0]; |
243 | 243 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return mixed|null |
251 | 251 | */ |
252 | - public function last(){ |
|
252 | + public function last() { |
|
253 | 253 | if (($cnt = $this->count()) > 0) { |
254 | 254 | return $this->values[$cnt - 1]; |
255 | 255 | } |
@@ -78,7 +78,9 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function toDate(): Carbon { |
80 | 80 | $date = $this->first(); |
81 | - if ($date instanceof Carbon) return $date; |
|
81 | + if ($date instanceof Carbon) { |
|
82 | + return $date; |
|
83 | + } |
|
82 | 84 | |
83 | 85 | return Carbon::parse($date); |
84 | 86 | } |
@@ -141,7 +143,7 @@ discard block |
||
141 | 143 | public function add($value, bool $strict = false): Attribute { |
142 | 144 | if (is_array($value)) { |
143 | 145 | return $this->merge($value, $strict); |
144 | - }elseif ($value !== null) { |
|
146 | + } elseif ($value !== null) { |
|
145 | 147 | $this->attach($value, $strict); |
146 | 148 | } |
147 | 149 | |
@@ -188,7 +190,7 @@ discard block |
||
188 | 190 | if ($this->contains($value) === false) { |
189 | 191 | $this->values[] = $value; |
190 | 192 | } |
191 | - }else{ |
|
193 | + } else{ |
|
192 | 194 | $this->values[] = $value; |
193 | 195 | } |
194 | 196 | } |
@@ -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 | |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @throws InvalidWhereQueryCriteriaException |
157 | 157 | */ |
158 | - protected function push_search_criteria(string $criteria, $value){ |
|
158 | + protected function push_search_criteria(string $criteria, $value) { |
|
159 | 159 | $criteria = $this->validate_criteria($criteria); |
160 | 160 | $value = $this->parse_value($value); |
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): WhereQuery { |
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): WhereQuery { |
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 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | if (ClientManager::get('options.fetch_order') === 'desc') { |
97 | 97 | $this->fetch_order = 'desc'; |
98 | - } else { |
|
98 | + }else { |
|
99 | 99 | $this->fetch_order = 'asc'; |
100 | 100 | } |
101 | 101 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | break; |
127 | 127 | } |
128 | 128 | |
129 | - return (string)$value; |
|
129 | + return (string) $value; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | $this->query->each(function($statement) use (&$query) { |
159 | 159 | if (count($statement) == 1) { |
160 | 160 | $query .= $statement[0]; |
161 | - } else { |
|
161 | + }else { |
|
162 | 162 | if ($statement[1] === null) { |
163 | 163 | $query .= $statement[0]; |
164 | - } else { |
|
164 | + }else { |
|
165 | 165 | if (is_numeric($statement[1])) { |
166 | - $query .= $statement[0] . ' ' . $statement[1]; |
|
167 | - } else { |
|
168 | - $query .= $statement[0] . ' "' . $statement[1] . '"'; |
|
166 | + $query .= $statement[0].' '.$statement[1]; |
|
167 | + }else { |
|
168 | + $query .= $statement[0].' "'.$statement[1].'"'; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $key = $message->getMessageId(); |
300 | 300 | break; |
301 | 301 | } |
302 | - return (string)$key; |
|
302 | + return (string) $key; |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $extensions = $raw_messages["extensions"][$uid] ?? []; |
348 | 348 | |
349 | 349 | $message = $this->make($uid, $msglist, $header, $content, $flag); |
350 | - foreach($extensions as $key => $extension) { |
|
350 | + foreach ($extensions as $key => $extension) { |
|
351 | 351 | $message->getHeader()->set($key, $extension); |
352 | 352 | } |
353 | 353 | if ($message !== null) { |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | $uids = $connection->getUid(); |
500 | 500 | $available_messages = new Collection(); |
501 | 501 | if (is_array($uids)) { |
502 | - foreach ($uids as $id){ |
|
502 | + foreach ($uids as $id) { |
|
503 | 503 | if ($closure($id)) { |
504 | 504 | $available_messages->push($id); |
505 | 505 | } |
@@ -91,7 +91,9 @@ discard block |
||
91 | 91 | $this->setClient($client); |
92 | 92 | |
93 | 93 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
94 | - if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
94 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
95 | + $this->leaveUnread(); |
|
96 | + } |
|
95 | 97 | |
96 | 98 | if (ClientManager::get('options.fetch_order') === 'desc') { |
97 | 99 | $this->fetch_order = 'desc'; |
@@ -137,7 +139,9 @@ discard block |
||
137 | 139 | * @throws MessageSearchValidationException |
138 | 140 | */ |
139 | 141 | protected function parse_date($date): Carbon { |
140 | - if ($date instanceof Carbon) return $date; |
|
142 | + if ($date instanceof Carbon) { |
|
143 | + return $date; |
|
144 | + } |
|
141 | 145 | |
142 | 146 | try { |
143 | 147 | $date = Carbon::parse($date); |
@@ -644,7 +648,9 @@ discard block |
||
644 | 648 | * @return $this |
645 | 649 | */ |
646 | 650 | public function limit(int $limit, int $page = 1): Query { |
647 | - if ($page >= 1) $this->page = $page; |
|
651 | + if ($page >= 1) { |
|
652 | + $this->page = $page; |
|
653 | + } |
|
648 | 654 | $this->limit = $limit; |
649 | 655 | |
650 | 656 | 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,12 +85,12 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Determine the message content type |
87 | 87 | */ |
88 | - public function findContentType(){ |
|
88 | + public function findContentType() { |
|
89 | 89 | $content_type = $this->header->get("content_type"); |
90 | 90 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
91 | - if(stripos($content_type, 'multipart') === 0) { |
|
91 | + if (stripos($content_type, 'multipart') === 0) { |
|
92 | 92 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
93 | - }else{ |
|
93 | + }else { |
|
94 | 94 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
95 | 95 | } |
96 | 96 | } |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * @throws InvalidMessageDateException |
128 | 128 | */ |
129 | 129 | private function detectParts(string $boundary, string $context, int $part_number = 0): array { |
130 | - $base_parts = explode( $boundary, $context); |
|
130 | + $base_parts = explode($boundary, $context); |
|
131 | 131 | $final_parts = []; |
132 | - foreach($base_parts as $ctx) { |
|
132 | + foreach ($base_parts as $ctx) { |
|
133 | 133 | $ctx = substr($ctx, 2); |
134 | 134 | if ($ctx !== "--" && $ctx != "") { |
135 | 135 | $parts = $this->parsePart($ctx, $part_number); |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * @throws InvalidMessageDateException |
152 | 152 | */ |
153 | 153 | public function find_parts(): array { |
154 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
155 | - if (($boundary = $this->header->getBoundary()) === null) { |
|
154 | + if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
155 | + if (($boundary = $this->header->getBoundary()) === null) { |
|
156 | 156 | throw new MessageContentFetchingException("no content found", 0); |
157 | 157 | } |
158 | 158 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return string|null |
169 | 169 | * @Depricated since version 2.4.4 |
170 | 170 | */ |
171 | - public function getBoundary(){ |
|
171 | + public function getBoundary() { |
|
172 | 172 | return $this->header->getBoundary(); |
173 | 173 | } |
174 | 174 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $this->part_number = $part->part_number; |
104 | 104 | |
105 | 105 | $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask(); |
106 | - if($default_mask != null) { |
|
106 | + if ($default_mask != null) { |
|
107 | 107 | $this->mask = $default_mask; |
108 | 108 | } |
109 | 109 | |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | * @throws MethodNotFoundException |
121 | 121 | */ |
122 | 122 | public function __call(string $method, array $arguments) { |
123 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
123 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
124 | 124 | $name = Str::snake(substr($method, 3)); |
125 | 125 | |
126 | - if(isset($this->attributes[$name])) { |
|
126 | + if (isset($this->attributes[$name])) { |
|
127 | 127 | return $this->attributes[$name]; |
128 | 128 | } |
129 | 129 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @return mixed|null |
160 | 160 | */ |
161 | 161 | public function __get($name) { |
162 | - if(isset($this->attributes[$name])) { |
|
162 | + if (isset($this->attributes[$name])) { |
|
163 | 163 | return $this->attributes[$name]; |
164 | 164 | } |
165 | 165 | |
@@ -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 | /** @var \Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser $deprecated_guesser */ |
284 | 284 | return $deprecated_guesser::getInstance()->guess($this->getMimeType()); |
285 | 285 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @return $this |
313 | 313 | */ |
314 | 314 | public function setMask($mask): Attachment { |
315 | - if(class_exists($mask)){ |
|
315 | + if (class_exists($mask)) { |
|
316 | 316 | $this->mask = $mask; |
317 | 317 | } |
318 | 318 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * @return mixed |
336 | 336 | * @throws MaskNotFoundException |
337 | 337 | */ |
338 | - public function mask($mask = null){ |
|
338 | + public function mask($mask = null) { |
|
339 | 339 | $mask = $mask !== null ? $mask : $this->mask; |
340 | - if(class_exists($mask)){ |
|
340 | + if (class_exists($mask)) { |
|
341 | 341 | return new $mask($this); |
342 | 342 | } |
343 | 343 |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported'); |
|
94 | + throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | if (isset($this->attributes[$name]) && $strict === false) { |
131 | 131 | if ($this->attributize) { |
132 | 132 | $this->attributes[$name]->add($value, true); |
133 | - } else { |
|
133 | + }else { |
|
134 | 134 | if (isset($this->attributes[$name])) { |
135 | 135 | if (is_array($this->attributes[$name]) == false) { |
136 | 136 | $this->attributes[$name] = [$this->attributes[$name], $value]; |
137 | - } else { |
|
137 | + }else { |
|
138 | 138 | $this->attributes[$name][] = $value; |
139 | 139 | } |
140 | - } else { |
|
140 | + }else { |
|
141 | 141 | $this->attributes[$name] = $value; |
142 | 142 | } |
143 | 143 | } |
144 | 144 | } elseif ($this->attributize == false) { |
145 | 145 | $this->attributes[$name] = $value; |
146 | - } else { |
|
146 | + }else { |
|
147 | 147 | $this->attributes[$name] = new Attribute($name, $value); |
148 | 148 | } |
149 | 149 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $headers = []; |
237 | 237 | $imap_headers = []; |
238 | 238 | if (extension_loaded('imap') && $this->config["rfc822"]) { |
239 | - $raw_imap_headers = (array)\imap_rfc822_parse_headers($this->raw); |
|
239 | + $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw); |
|
240 | 240 | foreach ($raw_imap_headers as $key => $values) { |
241 | 241 | $key = str_replace("-", "_", $key); |
242 | 242 | $imap_headers[$key] = $values; |
@@ -264,11 +264,11 @@ discard block |
||
264 | 264 | } |
265 | 265 | if (is_array($headers[$prev_header])) { |
266 | 266 | $headers[$prev_header][] = $line; |
267 | - } else { |
|
267 | + }else { |
|
268 | 268 | $headers[$prev_header] .= $line; |
269 | 269 | } |
270 | 270 | } |
271 | - } else { |
|
271 | + }else { |
|
272 | 272 | if (($pos = strpos($line, ":")) > 0) { |
273 | 273 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
274 | 274 | $key = str_replace("-", "_", $key); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $value = trim(rtrim(substr($line, $pos + 1))); |
277 | 277 | if (isset($headers[$key])) { |
278 | 278 | $headers[$key][] = $value; |
279 | - } else { |
|
279 | + }else { |
|
280 | 280 | $headers[$key] = [$value]; |
281 | 281 | } |
282 | 282 | $prev_header = $key; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | case 'reply_to': |
296 | 296 | case 'sender': |
297 | 297 | $value = $this->decodeAddresses($values); |
298 | - $headers[$key . "address"] = implode(", ", $values); |
|
298 | + $headers[$key."address"] = implode(", ", $values); |
|
299 | 299 | break; |
300 | 300 | case 'subject': |
301 | 301 | $value = implode(" ", $values); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $value = implode(" ", $values); |
315 | 315 | } elseif ($available_values > 2) { |
316 | 316 | $value = array_values($values); |
317 | - } else { |
|
317 | + }else { |
|
318 | 318 | $value = ""; |
319 | 319 | } |
320 | 320 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $headers[$key] = $value; |
324 | 324 | } |
325 | 325 | |
326 | - return (object)array_merge($headers, $imap_headers); |
|
326 | + return (object) array_merge($headers, $imap_headers); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | return \imap_mime_header_decode($text); |
340 | 340 | } |
341 | 341 | $charset = $this->getEncoding($text); |
342 | - return [(object)[ |
|
342 | + return [(object) [ |
|
343 | 343 | "charset" => $charset, |
344 | 344 | "text" => $this->convertEncoding($text, $charset) |
345 | 345 | ]]; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | try { |
394 | 394 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
395 | 395 | return iconv($from, $to, $str); |
396 | - } else { |
|
396 | + }else { |
|
397 | 397 | if (!$from) { |
398 | 398 | return mb_convert_encoding($str, $to); |
399 | 399 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | if (strstr($from, '-')) { |
404 | 404 | $from = str_replace('-', '', $from); |
405 | 405 | return $this->convertEncoding($str, $from, $to); |
406 | - } else { |
|
406 | + }else { |
|
407 | 407 | return $str; |
408 | 408 | } |
409 | 409 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | */ |
508 | 508 | private function findPriority() { |
509 | 509 | if (($priority = $this->get("x_priority")) === null) return; |
510 | - switch ((int)"$priority") { |
|
510 | + switch ((int) "$priority") { |
|
511 | 511 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
512 | 512 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
513 | 513 | break; |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | if (isset($parsed_address['address'])) { |
547 | 547 | $mail_address = explode('@', $parsed_address['address']); |
548 | 548 | if (count($mail_address) == 2) { |
549 | - $addresses[] = (object)[ |
|
549 | + $addresses[] = (object) [ |
|
550 | 550 | "personal" => $parsed_address['display'] ?? '', |
551 | 551 | "mailbox" => $mail_address[0], |
552 | 552 | "host" => $mail_address[1], |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $name = trim(rtrim($matches["name"])); |
575 | 575 | $email = trim(rtrim($matches["email"])); |
576 | 576 | list($mailbox, $host) = array_pad(explode("@", $email), 2, null); |
577 | - $addresses[] = (object)[ |
|
577 | + $addresses[] = (object) [ |
|
578 | 578 | "personal" => $name, |
579 | 579 | "mailbox" => $mailbox, |
580 | 580 | "host" => $host, |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | } |
613 | 613 | |
614 | 614 | foreach ($list as $item) { |
615 | - $address = (object)$item; |
|
615 | + $address = (object) $item; |
|
616 | 616 | |
617 | 617 | if (!property_exists($address, 'mailbox')) { |
618 | 618 | $address->mailbox = false; |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | } |
623 | 623 | if (!property_exists($address, 'personal')) { |
624 | 624 | $address->personal = false; |
625 | - } else { |
|
625 | + }else { |
|
626 | 626 | $personalParts = $this->mime_header_decode($address->personal); |
627 | 627 | |
628 | 628 | if (is_array($personalParts)) { |
@@ -637,8 +637,8 @@ discard block |
||
637 | 637 | } |
638 | 638 | } |
639 | 639 | |
640 | - $address->mail = ($address->mailbox && $address->host) ? $address->mailbox . '@' . $address->host : false; |
|
641 | - $address->full = ($address->personal) ? $address->personal . ' <' . $address->mail . '>' : $address->mail; |
|
640 | + $address->mail = ($address->mailbox && $address->host) ? $address->mailbox.'@'.$address->host : false; |
|
641 | + $address->full = ($address->personal) ? $address->personal.' <'.$address->mail.'>' : $address->mail; |
|
642 | 642 | |
643 | 643 | $addresses[] = new Address($address); |
644 | 644 | } |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | foreach ($this->attributes as $key => $value) { |
654 | 654 | if (is_array($value)) { |
655 | 655 | $value = implode(", ", $value); |
656 | - } else { |
|
657 | - $value = (string)$value; |
|
656 | + }else { |
|
657 | + $value = (string) $value; |
|
658 | 658 | } |
659 | 659 | // Only parse strings and don't parse any attributes like the user-agent |
660 | 660 | if (($key == "user_agent") === false) { |
@@ -734,8 +734,8 @@ discard block |
||
734 | 734 | $parsed_date = Carbon::parse($date); |
735 | 735 | } catch (\Exception $_e) { |
736 | 736 | if (!isset($this->config["fallback_date"])) { |
737 | - throw new InvalidMessageDateException("Invalid message date. ID:" . $this->get("message_id") . " Date:" . $header->date . "/" . $date, 1100, $e); |
|
738 | - } else { |
|
737 | + throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id")." Date:".$header->date."/".$date, 1100, $e); |
|
738 | + }else { |
|
739 | 739 | $parsed_date = Carbon::parse($this->config["fallback_date"]); |
740 | 740 | } |
741 | 741 | } |