Passed
Push — master ( 2b3dd9...f88783 )
by Chris
01:40
created
php/hamle/Text/Filter.php 1 patch
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -44,8 +44,9 @@  discard block
 block discarded – undo
44 44
     if(preg_match("/^([a-z]+)(?:\\((?P<vars>.*)\\))?(?:\\|(?P<chained>.+?))?$/", $s, $m)) {
45 45
       $this->filter = $m[1];
46 46
       $this->vars = isset($m['vars']) && strlen($m['vars']) ? explode(',', $m['vars']) : [];
47
-      foreach($this->vars as $k=>$v)
48
-        $this->vars[$k] = str_replace("&comma;",',',$v);
47
+      foreach($this->vars as $k=>$v) {
48
+              $this->vars[$k] = str_replace("&comma;",',',$v);
49
+      }
49 50
       if(isset($m['chained']) && strlen($m['chained'])) {
50 51
         $this->chained = new Filter($m['chained'],$what);
51 52
       }
@@ -60,31 +61,36 @@  discard block
 block discarded – undo
60 61
         $this->filter = "Seufert\\Hamle\\Text\\Filter::{$this->filter}";
61 62
     }
62 63
     $mapFilter = ['json'=>'json_encode'];
63
-    if(isset($mapFilter[$this->filter]))
64
-      $this->filter = $mapFilter[$this->filter];
64
+    if(isset($mapFilter[$this->filter])) {
65
+          $this->filter = $mapFilter[$this->filter];
66
+    }
65 67
     $this->what = $what;
66 68
   }
67 69
 
68 70
   function toHTML($escape = false) {
69
-    if($escape)
70
-      return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
71
+    if($escape) {
72
+          return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
73
+    }
71 74
     return "<?=" . $this->toPHP() . "?>";
72 75
   }
73 76
 
74 77
   function toPHPpre() {
75 78
     $pre = '';
76
-    if($this->chained)
77
-      $pre = $this->chained->toPHPpre();
79
+    if($this->chained) {
80
+          $pre = $this->chained->toPHPpre();
81
+    }
78 82
     return "$pre{$this->filter}(";
79 83
   }
80 84
 
81 85
   function toPHPpost() {
82 86
     $post = '';
83
-    if($this->chained)
84
-      $post = $this->chained->toPHPpost();
87
+    if($this->chained) {
88
+          $post = $this->chained->toPHPpost();
89
+    }
85 90
     $o = '';
86
-    foreach($this->vars as $v)
87
-      $o .= ','.$this->varToCode($v);
91
+    foreach($this->vars as $v) {
92
+          $o .= ','.$this->varToCode($v);
93
+    }
88 94
     return "$o)$post";
89 95
   }
90 96
 
@@ -99,8 +105,9 @@  discard block
 block discarded – undo
99 105
   static function itersplit($v, $sep = ",") {
100 106
     $o = [];
101 107
     foreach(explode($sep, $v) as $k=>$i) {
102
-      if($i)
103
-        $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k];
108
+      if($i) {
109
+              $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k];
110
+      }
104 111
     }
105 112
     return new WrapArray($o);
106 113
   }
Please login to merge, or discard this patch.