Completed
Pull Request — 5.0 (#1)
by Huberty
03:03
created
src/SwiftTwigMailTemplate.php 1 patch
Spacing   +16 added lines, -16 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);
@@ -297,13 +297,13 @@  discard block
 block discarded – undo
297 297
         /**///remove tags with content between them
298 298
         if (strlen($expand) > 0) {
299 299
             $e = explode('|', $expand);
300
-            for ($i = 0;$i < count($e);++$i) {
301
-                while (stripos($s, '<'.$e[$i]) > 0) {
302
-                    $len[1] = strlen('<'.$e[$i]);
303
-                    $pos[1] = stripos($s, '<'.$e[$i]);
304
-                    $pos[2] = stripos($s, $e[$i].'>', $pos[1] + $len[1]);
305
-                    $len[2] = $pos[2] - $pos[1] + $len[1];
306
-                    $x = substr($s, $pos[1], $len[2]);
300
+            for ($i = 0; $i < count($e); ++$i) {
301
+                while (stripos($s, '<'.$e[ $i ]) > 0) {
302
+                    $len[ 1 ] = strlen('<'.$e[ $i ]);
303
+                    $pos[ 1 ] = stripos($s, '<'.$e[ $i ]);
304
+                    $pos[ 2 ] = stripos($s, $e[ $i ].'>', $pos[ 1 ] + $len[ 1 ]);
305
+                    $len[ 2 ] = $pos[ 2 ] - $pos[ 1 ] + $len[ 1 ];
306
+                    $x = substr($s, $pos[ 1 ], $len[ 2 ]);
307 307
                     $s = str_replace($x, '', $s);
308 308
                 }
309 309
             }
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
     private function removeElement(string $s, string $openTag, string $closeTag)
331 331
     {
332 332
         while (stripos($s, $openTag) > 0) {
333
-            $pos[1] = stripos($s, $openTag);
334
-            $pos[2] = stripos($s, $closeTag, $pos[1]);
335
-            $len[1] = $pos[2] - $pos[1] + 1;
336
-            $x = substr($s, $pos[1], $len[1]);
333
+            $pos[ 1 ] = stripos($s, $openTag);
334
+            $pos[ 2 ] = stripos($s, $closeTag, $pos[ 1 ]);
335
+            $len[ 1 ] = $pos[ 2 ] - $pos[ 1 ] + 1;
336
+            $x = substr($s, $pos[ 1 ], $len[ 1 ]);
337 337
             $s = str_replace($x, '', $s);
338 338
         }
339 339
 
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
     private function keepTag(string $s, array $tagToKeep, string $initial, string $finalize):string
352 352
     {
353 353
         $count = count($tagToKeep);
354
-        for ($i = 0;$i < $count;++$i) {
355
-            $s = str_replace($initial.$tagToKeep[$i], $finalize.$tagToKeep[$i], $s);
356
-            $s = str_replace($initial.'/'.$tagToKeep[$i], $finalize.'/'.$tagToKeep[$i], $s);
354
+        for ($i = 0; $i < $count; ++$i) {
355
+            $s = str_replace($initial.$tagToKeep[ $i ], $finalize.$tagToKeep[ $i ], $s);
356
+            $s = str_replace($initial.'/'.$tagToKeep[ $i ], $finalize.'/'.$tagToKeep[ $i ], $s);
357 357
         }
358 358
 
359 359
         return $s;
Please login to merge, or discard this patch.