Passed
Push — master ( 2b3dd9...f88783 )
by Chris
01:40
created
php/hamle/Text/Filter.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -41,49 +41,49 @@  discard block
 block discarded – undo
41 41
   protected $chained;
42 42
 
43 43
   function __construct($s, Text $what) {
44
-    if(preg_match("/^([a-z]+)(?:\\((?P<vars>.*)\\))?(?:\\|(?P<chained>.+?))?$/", $s, $m)) {
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);
49
-      if(isset($m['chained']) && strlen($m['chained'])) {
50
-        $this->chained = new Filter($m['chained'],$what);
47
+      foreach ($this->vars as $k=>$v)
48
+        $this->vars[$k] = str_replace("&comma;", ',', $v);
49
+      if (isset($m['chained']) && strlen($m['chained'])) {
50
+        $this->chained = new Filter($m['chained'], $what);
51 51
       }
52 52
     } else {
53 53
       throw new ParseError("Unable to parse filter expression \"$s\"");
54 54
     }
55
-    if(!in_array($this->filter, ['itersplit', 'newlinebr', 'round',
56
-        'strtoupper', 'strtolower', 'ucfirst','replace', 'json'])) {
55
+    if (!in_array($this->filter, ['itersplit', 'newlinebr', 'round',
56
+        'strtoupper', 'strtolower', 'ucfirst', 'replace', 'json'])) {
57 57
       throw new ParseError("Unknown Filter Type \"{$this->filter}\"");
58 58
     }
59
-    if(in_array($this->filter,['itersplit','newlinebr', 'replace'])) {
59
+    if (in_array($this->filter, ['itersplit', 'newlinebr', 'replace'])) {
60 60
         $this->filter = "Seufert\\Hamle\\Text\\Filter::{$this->filter}";
61 61
     }
62 62
     $mapFilter = ['json'=>'json_encode'];
63
-    if(isset($mapFilter[$this->filter]))
63
+    if (isset($mapFilter[$this->filter]))
64 64
       $this->filter = $mapFilter[$this->filter];
65 65
     $this->what = $what;
66 66
   }
67 67
 
68 68
   function toHTML($escape = false) {
69
-    if($escape)
70
-      return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
71
-    return "<?=" . $this->toPHP() . "?>";
69
+    if ($escape)
70
+      return "<?=htmlspecialchars(".$this->toPHP().")?>";
71
+    return "<?=".$this->toPHP()."?>";
72 72
   }
73 73
 
74 74
   function toPHPpre() {
75 75
     $pre = '';
76
-    if($this->chained)
76
+    if ($this->chained)
77 77
       $pre = $this->chained->toPHPpre();
78 78
     return "$pre{$this->filter}(";
79 79
   }
80 80
 
81 81
   function toPHPpost() {
82 82
     $post = '';
83
-    if($this->chained)
83
+    if ($this->chained)
84 84
       $post = $this->chained->toPHPpost();
85 85
     $o = '';
86
-    foreach($this->vars as $v)
86
+    foreach ($this->vars as $v)
87 87
       $o .= ','.$this->varToCode($v);
88 88
     return "$o)$post";
89 89
   }
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
 
99 99
   static function itersplit($v, $sep = ",") {
100 100
     $o = [];
101
-    foreach(explode($sep, $v) as $k=>$i) {
102
-      if($i)
103
-        $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k];
101
+    foreach (explode($sep, $v) as $k=>$i) {
102
+      if ($i)
103
+        $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k, 'key'=>$k];
104 104
     }
105 105
     return new WrapArray($o);
106 106
   }
107 107
 
108 108
   static function newlinebr($v) {
109
-    return str_replace("\n","<br />\n",$v);
109
+    return str_replace("\n", "<br />\n", $v);
110 110
   }
111 111
 
112 112
   static function replace($v, $src, $dst) {
113
-    return str_replace($src,$dst,$v);
113
+    return str_replace($src, $dst, $v);
114 114
   }
115 115
 
116 116
 }
117 117
\ No newline at end of file
Please login to merge, or discard this patch.