Completed
Push — master ( bbd140...a7f3dd )
by Chris
03:02
created
php/hamle/Text/Filter.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -13,6 +13,9 @@
 block discarded – undo
13 13
   protected $s;
14 14
   protected $type;
15 15
 
16
+  /**
17
+   * @param string $s
18
+   */
16 19
   function __construct($s, $type = self::TOKEN_HTML) {
17 20
     $this->s = str_replace('\\$', "$", $s);
18 21
     $this->type = $type;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,28 +37,28 @@
 block discarded – undo
37 37
   protected $what;
38 38
 
39 39
   function __construct($s, Text $what) {
40
-    if(preg_match("/^([a-z]+)(\\((.*)\\))?$/",$s, $m)) {
40
+    if (preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) {
41 41
       $this->filter = $m[1];
42
-      $this->vars = isset($m[3])?explode(',',$m[3]):[];
42
+      $this->vars = isset($m[3]) ? explode(',', $m[3]) : [];
43 43
     } else {
44 44
       throw new ParseError("Unable to parse filter expression \"$s\"");
45 45
     }
46
-    if(!in_array($this->filter,['round','strtoupper','strtolower','ucfirst'])) {
46
+    if (!in_array($this->filter, ['round', 'strtoupper', 'strtolower', 'ucfirst'])) {
47 47
       throw new ParseError("Unknown Filter Type \"{$this->filter}\"");
48 48
     }
49 49
     $this->what = $what;
50 50
   }
51 51
 
52 52
   function toHTML($escape = false) {
53
-    if($escape)
54
-      return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
53
+    if ($escape)
54
+      return "<?=htmlspecialchars(" . $this->toPHP() . ")?>";
55 55
     return "<?=" . $this->toPHP() . "?>";
56 56
   }
57 57
 
58 58
   function toPHP() {
59
-    $o = [$this->what->toPHPVar()] ;
60
-    foreach($this->vars as $v)
59
+    $o = [$this->what->toPHPVar()];
60
+    foreach ($this->vars as $v)
61 61
       $o[] = $this->varToCode($v);
62
-    return "{$this->filter}(" . implode(',',$o) . ")";
62
+    return "{$this->filter}(" . implode(',', $o) . ")";
63 63
   }
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.