Completed
Push — master ( 4bd5ba...8468f5 )
by Chris
02:39
created
php/hamle/Text/Complex.php 1 patch
Braces   +22 added lines, -14 removed lines patch added patch discarded remove patch
@@ -39,21 +39,27 @@  discard block
 block discarded – undo
39 39
       $s = substr($s,0,$pos);
40 40
     }
41 41
     $s = explode("->", $s);
42
-    if(count($s) == 1) $s = explode("-!",$s[0]);
43
-    if (!$s[0]) throw new ParseError("Unable to parse Complex Expression");
44
-    if ($s[0][1] == "(")
45
-      $this->func = new Text\Func($s[0]);
46
-    elseif ($s[0][1] == "[")
47
-      $this->func = new Text\Scope($s[0]);
48
-    else
49
-      $this->func = new SimpleVar($s[0]);
42
+    if(count($s) == 1) {
43
+      $s = explode("-!",$s[0]);
44
+    }
45
+    if (!$s[0]) {
46
+      throw new ParseError("Unable to parse Complex Expression");
47
+    }
48
+    if ($s[0][1] == "(") {
49
+          $this->func = new Text\Func($s[0]);
50
+    } elseif ($s[0][1] == "[") {
51
+          $this->func = new Text\Scope($s[0]);
52
+    } else {
53
+          $this->func = new SimpleVar($s[0]);
54
+    }
50 55
     array_shift($s);
51 56
     $this->sel = $s;
52 57
   }
53 58
 
54 59
   function toHTML($escape = false) {
55
-    if($escape)
56
-      return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
60
+    if($escape) {
61
+          return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
62
+    }
57 63
     return "<?=" . $this->toPHP() . "?>";
58 64
   }
59 65
   function toPHP() {
@@ -62,11 +68,13 @@  discard block
 block discarded – undo
62 68
   function toPHPVar() {
63 69
     if ($this->sel) {
64 70
       $sel = array();
65
-      foreach ($this->sel as $s)
66
-        $sel[] = "hamleGet('$s')";
71
+      foreach ($this->sel as $s) {
72
+              $sel[] = "hamleGet('$s')";
73
+      }
67 74
       return $this->func->toPHP() . "->" . implode('->', $sel);
68
-    } else
69
-      return $this->func->toPHP();
75
+    } else {
76
+          return $this->func->toPHP();
77
+    }
70 78
   }
71 79
 
72 80
 }
73 81
\ No newline at end of file
Please login to merge, or discard this patch.