Passed
Push — master ( 453007...cbc44e )
by Chris
03:29
created
php/hamle/Text/Complex.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
   protected $filter;
39 39
 
40 40
   function __construct($s) {
41
-    if(FALSE !== $pos = strpos($s,'|')) {
42
-      $this->filter = new Filter(substr($s, $pos+1), $this);
43
-      $s = substr($s,0,$pos);
41
+    if (FALSE !== $pos = strpos($s, '|')) {
42
+      $this->filter = new Filter(substr($s, $pos + 1), $this);
43
+      $s = substr($s, 0, $pos);
44 44
     }
45 45
     $s = preg_split("/-[>!]/", $s);
46 46
     // if(count($s) == 1) $s = explode("-!",$s[0]);
@@ -56,27 +56,27 @@  discard block
 block discarded – undo
56 56
   }
57 57
 
58 58
   function toHTML($escape = false) {
59
-    if($escape)
60
-      return "<?=htmlspecialchars(" .$this->toPHP() . ")?>";
61
-    return "<?=" . $this->toPHP() . "?>";
59
+    if ($escape)
60
+      return "<?=htmlspecialchars(".$this->toPHP().")?>";
61
+    return "<?=".$this->toPHP()."?>";
62 62
   }
63 63
   function toPHP() {
64
-    return $this->filter?$this->filter->toPHP():$this->toPHPVar();
64
+    return $this->filter ? $this->filter->toPHP() : $this->toPHPVar();
65 65
   }
66 66
   function toPHPVar() {
67 67
     if ($this->sel) {
68 68
       $sel = array();
69 69
       foreach ($this->sel as $s)
70 70
         $sel[] = "hamleGet('$s')";
71
-      return $this->func->toPHP() . "->" . implode('->', $sel);
71
+      return $this->func->toPHP()."->".implode('->', $sel);
72 72
     } else
73 73
       return $this->func->toPHP();
74 74
   }
75 75
 
76 76
   function getOrCreateModel(Model $parent = null) {
77
-    if($this->func instanceof Text\Scope)
77
+    if ($this->func instanceof Text\Scope)
78 78
       return $this->func->getOrCreateModel($parent);
79
-    if($this->func instanceof Text\Func)
79
+    if ($this->func instanceof Text\Func)
80 80
       return $this->func->getOrCreateModel($parent);
81 81
   }
82 82
 
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
    * @return WriteModel
86 86
    */
87 87
   function setValue($value) {
88
-    if(!$this->sel || count($this->sel) != 1)
88
+    if (!$this->sel || count($this->sel) != 1)
89 89
       throw new \RuntimeException('Can only set values, when one var name is present');
90 90
     $model = $this->getOrCreateModel();
91
-    if(!$model instanceof WriteModel)
91
+    if (!$model instanceof WriteModel)
92 92
       throw new \RuntimeException('Can only set values on WriteModels, got '.get_class($model));
93 93
     $model->hamleSet($this->sel[0], $value);
94 94
     return $model;
Please login to merge, or discard this patch.