Completed
Pull Request — 5.0 (#6)
by Huberty
05:35
created
src/SwiftTwigMailTemplate.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -325,7 +325,7 @@
 block discarded – undo
325 325
      * @param string $openTag
326 326
      * @param string $closeTag
327 327
      *
328
-     * @return mixed|string
328
+     * @return string
329 329
      */
330 330
     private function removeElement(string $s, string $openTag, string $closeTag)
331 331
     {
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
      *
104 104
      * @return \Swift_Message
105 105
      */
106
-    public function renderMail(array $data = []) :\Swift_Message
106
+    public function renderMail(array $data = [ ]) :\Swift_Message
107 107
     {
108 108
         $mail = new \Swift_Message();
109 109
 
110 110
         $twigEnvironment = clone $this->twigEnvironment;
111
-        $function = new \Twig_SimpleFunction('embedImage', function ($imgPath) use ($mail) {
111
+        $function = new \Twig_SimpleFunction('embedImage', function($imgPath) use ($mail) {
112 112
             return $mail->embed(\Swift_Image::fromPath($imgPath));
113 113
         });
114 114
         $twigEnvironment->addFunction($function);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         }
140 140
 
141 141
         $i = 0;
142
-        while($i != 10) {
142
+        while ($i != 10) {
143 143
             switch (true) {
144 144
                 case $this->fromAddresses && $i < 1 :
145 145
                     $i = 1;
@@ -324,15 +324,15 @@  discard block
 block discarded – undo
324 324
         if (strlen($expand) > 0) {
325 325
             $e = explode('|', $expand);
326 326
             $count = count($e);
327
-            $pos = [];
328
-            $len = [];
329
-            for ($i = 0;$i < $count;++$i) {
330
-                while (stripos($s, '<'.$e[$i]) > 0) {
331
-                    $len[1] = strlen('<'.$e[$i]);
332
-                    $pos[1] = stripos($s, '<'.$e[$i]);
333
-                    $pos[2] = stripos($s, $e[$i].'>', $pos[1] + $len[1]);
334
-                    $len[2] = $pos[2] - $pos[1] + $len[1];
335
-                    $x = substr($s, $pos[1], $len[2]);
327
+            $pos = [ ];
328
+            $len = [ ];
329
+            for ($i = 0; $i < $count; ++$i) {
330
+                while (stripos($s, '<'.$e[ $i ]) > 0) {
331
+                    $len[ 1 ] = strlen('<'.$e[ $i ]);
332
+                    $pos[ 1 ] = stripos($s, '<'.$e[ $i ]);
333
+                    $pos[ 2 ] = stripos($s, $e[ $i ].'>', $pos[ 1 ] + $len[ 1 ]);
334
+                    $len[ 2 ] = $pos[ 2 ] - $pos[ 1 ] + $len[ 1 ];
335
+                    $x = substr($s, $pos[ 1 ], $len[ 2 ]);
336 336
                     $s = str_replace($x, '', $s);
337 337
                 }
338 338
             }
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
      */
359 359
     private function removeElement(string $s, string $openTag, string $closeTag)
360 360
     {
361
-        $pos = [];
362
-        $len = [];
361
+        $pos = [ ];
362
+        $len = [ ];
363 363
         while (stripos($s, $openTag) > 0) {
364
-            $pos[1] = stripos($s, $openTag);
365
-            $pos[2] = stripos($s, $closeTag, $pos[1]);
366
-            $len[1] = $pos[2] - $pos[1] + 1;
367
-            $x = substr($s, $pos[1], $len[1]);
364
+            $pos[ 1 ] = stripos($s, $openTag);
365
+            $pos[ 2 ] = stripos($s, $closeTag, $pos[ 1 ]);
366
+            $len[ 1 ] = $pos[ 2 ] - $pos[ 1 ] + 1;
367
+            $x = substr($s, $pos[ 1 ], $len[ 1 ]);
368 368
             $s = str_replace($x, '', $s);
369 369
         }
370 370
 
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
     private function keepTag(string $s, array $tagToKeep, string $initial, string $finalize):string
383 383
     {
384 384
         $count = count($tagToKeep);
385
-        for ($i = 0;$i < $count;++$i) {
386
-            $s = str_replace($initial.$tagToKeep[$i], $finalize.$tagToKeep[$i], $s);
387
-            $s = str_replace($initial.'/'.$tagToKeep[$i], $finalize.'/'.$tagToKeep[$i], $s);
385
+        for ($i = 0; $i < $count; ++$i) {
386
+            $s = str_replace($initial.$tagToKeep[ $i ], $finalize.$tagToKeep[ $i ], $s);
387
+            $s = str_replace($initial.'/'.$tagToKeep[ $i ], $finalize.'/'.$tagToKeep[ $i ], $s);
388 388
         }
389 389
 
390 390
         return $s;
Please login to merge, or discard this patch.