@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | |
31 | 31 | public function __construct(array $allowedHeaders = array(), array $removeHeaders = array()) |
32 | 32 | { |
33 | - $this->contentDecoder = new ContentDecoder (); |
|
34 | - $this->headerDecoder = new HeaderDecoder (); |
|
33 | + $this->contentDecoder = new ContentDecoder(); |
|
34 | + $this->headerDecoder = new HeaderDecoder(); |
|
35 | 35 | |
36 | 36 | $this->allowedHeaders = array_merge($this->allowedHeaders, $allowedHeaders); |
37 | 37 | $this->removeHeaders = array_merge($this->removeHeaders, $removeHeaders); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $parts = $this->parseParts($stream, $partHeaders); |
91 | 91 | |
92 | 92 | if (!$message) { |
93 | - $message = new \Swift_Message (); |
|
93 | + $message = new \Swift_Message(); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $headers = $this->createHeadersSet($filteredHeaders); |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | break; |
116 | 116 | } |
117 | 117 | if (preg_match('/^([a-z0-9\-]+)\s*:(.*)/i', $row, $mch)) { |
118 | - $hName = strtolower($mch[1]); |
|
118 | + $hName = strtolower($mch[ 1 ]); |
|
119 | 119 | if (!in_array($hName, array("content-type", "content-transfer-encoding"))) { |
120 | - $hName = $mch[1]; |
|
120 | + $hName = $mch[ 1 ]; |
|
121 | 121 | } |
122 | - $row = $mch[2]; |
|
122 | + $row = $mch[ 2 ]; |
|
123 | 123 | } |
124 | 124 | if (empty($hName)) { |
125 | 125 | continue; |
126 | 126 | } |
127 | - $headers[$hName][] = trim($row); |
|
127 | + $headers[ $hName ][ ] = trim($row); |
|
128 | 128 | } |
129 | 129 | foreach ($headers as $header => $values) { |
130 | - $headers[$header] = $this->headerDecoder->decode(trim(implode(" ", $values))); |
|
130 | + $headers[ $header ] = $this->headerDecoder->decode(trim(implode(" ", $values))); |
|
131 | 131 | } |
132 | 132 | return $headers; |
133 | 133 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | { |
137 | 137 | foreach ($headers as $header => $values) { |
138 | 138 | if (in_array(strtolower($header), $this->removeHeaders) && !in_array(strtolower($header), $this->allowedHeaders)) { |
139 | - unset ($headers[$header]); |
|
139 | + unset ($headers[ $header ]); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | return $headers; |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | $boundary = null; |
151 | 151 | if (stripos($contentType, 'multipart/') !== false) { |
152 | 152 | $headerParts = $this->extractHeaderParts($this->getContentType($partHeaders)); |
153 | - if (empty($headerParts["boundary"])) { |
|
153 | + if (empty($headerParts[ "boundary" ])) { |
|
154 | 154 | throw new InvalidMessageFormatException("The Content-Type header is not well formed, boundary is missing"); |
155 | 155 | } |
156 | - $boundary = $headerParts["boundary"]; |
|
156 | + $boundary = $headerParts[ "boundary" ]; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | try { |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | $childContentType = $this->extractValueHeader($this->getContentType($partHeaders)); |
178 | 178 | |
179 | 179 | if (stripos($childContentType, 'multipart/') !== false) { |
180 | - $parts["parts"][] = $this->parseParts($stream, $partHeaders); |
|
180 | + $parts[ "parts" ][ ] = $this->parseParts($stream, $partHeaders); |
|
181 | 181 | } else { |
182 | 182 | $this->extractPart($stream, $boundary, $this->getTransferEncoding($partHeaders)); |
183 | 183 | } |
184 | 184 | } catch (Exception\EndOfPartReachedException $e) { |
185 | - $parts["parts"][] = array( |
|
185 | + $parts[ "parts" ][ ] = array( |
|
186 | 186 | "type" => $childContentType, |
187 | 187 | "parent-type" => $contentType, |
188 | 188 | "headers" => $partHeaders, |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | private function getContentType(array $partHeaders): string |
213 | 213 | { |
214 | 214 | if (array_key_exists('content-type', $partHeaders)) { |
215 | - return $partHeaders['content-type']; |
|
215 | + return $partHeaders[ 'content-type' ]; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | return ''; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | continue; |
231 | 231 | } |
232 | 232 | list ($k, $v) = explode("=", trim($pv), 2); |
233 | - $p[$k] = trim($v, '"'); |
|
233 | + $p[ $k ] = trim($v, '"'); |
|
234 | 234 | } |
235 | 235 | return $p; |
236 | 236 | } else { |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | throw new Exception\EndOfPartReachedException($this->contentDecoder->decode(implode("", $rows), $encoding)); |
257 | 257 | } |
258 | 258 | } |
259 | - $rows[] = $row; |
|
259 | + $rows[ ] = $row; |
|
260 | 260 | } |
261 | 261 | throw new Exception\EndOfMultiPartReachedException($this->contentDecoder->decode(implode("", $rows), $encoding)); |
262 | 262 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | private function getTransferEncoding(array $partHeaders): string |
265 | 265 | { |
266 | 266 | if (array_key_exists('content-transfer-encoding', $partHeaders)) { |
267 | - return $partHeaders['content-transfer-encoding']; |
|
267 | + return $partHeaders[ 'content-transfer-encoding' ]; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | return ''; |
@@ -278,13 +278,13 @@ discard block |
||
278 | 278 | switch (strtolower($name)) { |
279 | 279 | case "content-type": |
280 | 280 | $parts = $this->extractHeaderParts($value); |
281 | - unset ($parts["boundary"]); |
|
281 | + unset ($parts[ "boundary" ]); |
|
282 | 282 | $headers->addParameterizedHeader($name, $this->extractValueHeader($value), $parts); |
283 | 283 | break; |
284 | 284 | case "return-path": |
285 | 285 | if (preg_match_all('/([a-z][a-z0-9_\-\.]*@[a-z0-9\.\-]*\.[a-z]{2,5})/i', $value, $mch)) { |
286 | - foreach ($mch[0] as $k => $mails) { |
|
287 | - $headers->addPathHeader($name, $mch[1][$k]); |
|
286 | + foreach ($mch[ 0 ] as $k => $mails) { |
|
287 | + $headers->addPathHeader($name, $mch[ 1 ][ $k ]); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | break; |
@@ -298,16 +298,16 @@ discard block |
||
298 | 298 | case "cc": |
299 | 299 | $adresses = array(); |
300 | 300 | if (preg_match_all('/(.*?)<([a-z][a-z0-9_\-\.]*@[a-z0-9\.\-]*\.[a-z]{2,5})>\s*[;,]*/i', $value, $mch)) { |
301 | - foreach ($mch[0] as $k => $mail) { |
|
302 | - if (!$mch[1][$k]) { |
|
303 | - $adresses[$mch[2][$k]] = trim($mch[2][$k]); |
|
301 | + foreach ($mch[ 0 ] as $k => $mail) { |
|
302 | + if (!$mch[ 1 ][ $k ]) { |
|
303 | + $adresses[ $mch[ 2 ][ $k ] ] = trim($mch[ 2 ][ $k ]); |
|
304 | 304 | } else { |
305 | - $adresses[$mch[2][$k]] = trim($mch[1][$k]); |
|
305 | + $adresses[ $mch[ 2 ][ $k ] ] = trim($mch[ 1 ][ $k ]); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } elseif (preg_match_all('/([a-z][a-z0-9_\-\.]*@[a-z0-9\.\-]*\.[a-z]{2,5})/i', $value, $mch)) { |
309 | - foreach ($mch[0] as $k => $mails) { |
|
310 | - $adresses[$mch[1][$k]] = trim($mch[1][$k]); |
|
309 | + foreach ($mch[ 0 ] as $k => $mails) { |
|
310 | + $adresses[ $mch[ 1 ][ $k ] ] = trim($mch[ 1 ][ $k ]); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | $headers->addMailboxHeader($name, $adresses); |
@@ -322,44 +322,44 @@ discard block |
||
322 | 322 | |
323 | 323 | protected function createMessage(array $message, \Swift_Mime_SimpleMimeEntity $entity): void |
324 | 324 | { |
325 | - if (stripos($message["type"], 'multipart/') !== false && !empty($message["parts"])) { |
|
325 | + if (stripos($message[ "type" ], 'multipart/') !== false && !empty($message[ "parts" ])) { |
|
326 | 326 | |
327 | - if (strpos($message["type"], '/alternative')) { |
|
327 | + if (strpos($message[ "type" ], '/alternative')) { |
|
328 | 328 | $nestingLevel = \Swift_Mime_SimpleMimeEntity::LEVEL_ALTERNATIVE; |
329 | - } elseif (strpos($message["type"], '/related')) { |
|
329 | + } elseif (strpos($message[ "type" ], '/related')) { |
|
330 | 330 | $nestingLevel = \Swift_Mime_SimpleMimeEntity::LEVEL_RELATED; |
331 | - } elseif (strpos($message["type"], '/mixed')) { |
|
331 | + } elseif (strpos($message[ "type" ], '/mixed')) { |
|
332 | 332 | $nestingLevel = \Swift_Mime_SimpleMimeEntity::LEVEL_MIXED; |
333 | 333 | } else { |
334 | 334 | $nestingLevel = \Swift_Mime_SimpleMimeEntity::LEVEL_TOP; |
335 | 335 | } |
336 | 336 | |
337 | 337 | $childs = array(); |
338 | - foreach ($message["parts"] as $part) { |
|
338 | + foreach ($message[ "parts" ] as $part) { |
|
339 | 339 | |
340 | - $headers = $this->createHeadersSet($part["headers"]); |
|
341 | - $encoder = $this->getEncoder($this->getTransferEncoding($part["headers"])); |
|
340 | + $headers = $this->createHeadersSet($part[ "headers" ]); |
|
341 | + $encoder = $this->getEncoder($this->getTransferEncoding($part[ "headers" ])); |
|
342 | 342 | |
343 | - if (stripos($part["type"], 'multipart/') !== false) { |
|
344 | - $newEntity = new \Swift_Mime_MimePart ($headers, $encoder, $this->getCache(), $this->getIdGenertor()); |
|
343 | + if (stripos($part[ "type" ], 'multipart/') !== false) { |
|
344 | + $newEntity = new \Swift_Mime_MimePart($headers, $encoder, $this->getCache(), $this->getIdGenertor()); |
|
345 | 345 | } else { |
346 | - $newEntity = new \Swift_Mime_SimpleMimeEntity ($headers, $encoder, $this->getCache(), $this->getIdGenertor()); |
|
346 | + $newEntity = new \Swift_Mime_SimpleMimeEntity($headers, $encoder, $this->getCache(), $this->getIdGenertor()); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | $this->createMessage($part, $newEntity); |
350 | 350 | |
351 | - $ref = new \ReflectionObject ($newEntity); |
|
351 | + $ref = new \ReflectionObject($newEntity); |
|
352 | 352 | $m = $ref->getMethod('setNestingLevel'); |
353 | 353 | $m->setAccessible(true); |
354 | 354 | $m->invoke($newEntity, $nestingLevel); |
355 | 355 | |
356 | - $childs[] = $newEntity; |
|
356 | + $childs[ ] = $newEntity; |
|
357 | 357 | } |
358 | 358 | |
359 | - $entity->setContentType($part["type"]); |
|
359 | + $entity->setContentType($part[ "type" ]); |
|
360 | 360 | $entity->setChildren($childs); |
361 | 361 | } else { |
362 | - $entity->setBody($message["body"], $message["type"]); |
|
362 | + $entity->setBody($message[ "body" ], $message[ "type" ]); |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 |