Passed
Push — master ( 97c601...68425f )
by Chris
03:55
created
php/hamle/Text/FuncSub.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
    */
40 40
   public function __construct($s) {
41 41
     $m = array();
42
-    if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m))
42
+    if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL.'+)(.*)$/', $s, $m))
43 43
       throw new ParseError("Unable to read \$ sub func in '$s'");
44 44
     if ($m[1] == "<") $this->dir = Hamle\Hamle::REL_PARENT;
45 45
     elseif ($m[1] == ">") $this->dir = Hamle\Hamle::REL_CHILD;
@@ -57,24 +57,24 @@  discard block
 block discarded – undo
57 57
    * @return string
58 58
    */
59 59
   public function toPHP() {
60
-    $limit = Hamle\Text::varToCode($this->sortlimit['sort']) . "," .
61
-        $this->sortlimit['limit'] . "," . $this->sortlimit['offset'] . "," .
60
+    $limit = Hamle\Text::varToCode($this->sortlimit['sort']).",".
61
+        $this->sortlimit['limit'].",".$this->sortlimit['offset'].",".
62 62
         $this->grouptype['grouptype'];
63
-    $sub = $this->sub ? "->" . $this->sub->toPHP() : "";
64
-    return "hamleRel(" . $this->dir . "," .
65
-    Hamle\Text::varToCode($this->filt['tag']) . ",$limit)$sub";
63
+    $sub = $this->sub ? "->".$this->sub->toPHP() : "";
64
+    return "hamleRel(".$this->dir.",".
65
+    Hamle\Text::varToCode($this->filt['tag']).",$limit)$sub";
66 66
   }
67 67
 
68 68
   public function getOrCreateModel(Model $parent = null) {
69 69
     $model = $parent->hamleRel($this->dir, $this->filt['tag'], $this->sortlimit['sort'],
70 70
       $this->sortlimit['limit'], $this->sortlimit['offset']);
71
-    if(!$model->valid()) {
72
-      if(!$parent instanceof Hamle\WriteModel)
73
-        throw new \Exception('Cant create model, ' . get_class($parent) . ' must implement Hamle\\WriteModel.');
71
+    if (!$model->valid()) {
72
+      if (!$parent instanceof Hamle\WriteModel)
73
+        throw new \Exception('Cant create model, '.get_class($parent).' must implement Hamle\\WriteModel.');
74 74
       $model = $parent->current()->hamleCreateRel($this->dir, $this->filt['tag'], $this->sortlimit['sort'],
75 75
         $this->sortlimit['limit'], $this->sortlimit['offset']);
76 76
     }
77
-    if($this->sub)
77
+    if ($this->sub)
78 78
       return $this->sub->getOrCreateModel($model)->current();
79 79
     return $model->current();
80 80
   }
Please login to merge, or discard this patch.
php/hamle/Text/Func.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
    */
51 51
   public function __construct($s) {
52 52
     $m = array();
53
-    if (!preg_match('/^\$\((' . self::REGEX_FUNCSEL . '*)(.*)\)$/', $s, $m))
53
+    if (!preg_match('/^\$\(('.self::REGEX_FUNCSEL.'*)(.*)\)$/', $s, $m))
54 54
       throw new ParseError("Unable to read \$ func in '$s'");
55 55
     if (trim($m[2]))
56 56
       $this->sub = new FuncSub($m[2]);
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
     }
93 93
     $rand = false;
94 94
     if (preg_match_all('/\\^(-?)([a-zA-Z0-9\_]*)/', $s, $m)) {
95
-      foreach($m[0] as $k=>$mv)
95
+      foreach ($m[0] as $k=>$mv)
96 96
         if ($m[2][$k]) {
97
-          $dir = $m[1][$k] == "-"?Hamle\Hamle::SORT_DESCENDING:Hamle\Hamle::SORT_ASCENDING;
97
+          $dir = $m[1][$k] == "-" ?Hamle\Hamle::SORT_DESCENDING : Hamle\Hamle::SORT_ASCENDING;
98 98
           $att['sort'][$m[2][$k]] = $dir;
99 99
         } else $rand = true;
100 100
     }
101
-    if($rand)
101
+    if ($rand)
102 102
       $att['sort'] = [""=>$att['dir'] = Hamle\Hamle::SORT_RANDOM];
103 103
     return $att;
104 104
   }
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
    * @return string PHP Code
117 117
    */
118 118
   public function toPHP() {
119
-    $sub = $this->sub ? "->" . $this->sub->toPHP() : "";
120
-    if($this->scope instanceof Scope) {
121
-      return $this->scope->toPHP() . $sub;
122
-    } elseif($this->scope === true) {
119
+    $sub = $this->sub ? "->".$this->sub->toPHP() : "";
120
+    if ($this->scope instanceof Scope) {
121
+      return $this->scope->toPHP().$sub;
122
+    } elseif ($this->scope === true) {
123 123
       return "Hamle\\Scope::get(0)$sub";
124 124
     }
125
-    $limit = Text::varToCode($this->sortlimit['sort']) . "," .
126
-        $this->sortlimit['limit'] . "," . $this->sortlimit['offset'];
125
+    $limit = Text::varToCode($this->sortlimit['sort']).",".
126
+        $this->sortlimit['limit'].",".$this->sortlimit['offset'];
127 127
     if (count($this->filt['tag']))
128
-      return "Hamle\\Run::modelTypeTags(" .
129
-      Text::varToCode($this->filt['tag']) . ",$limit)$sub";
128
+      return "Hamle\\Run::modelTypeTags(".
129
+      Text::varToCode($this->filt['tag']).",$limit)$sub";
130 130
     if (count($this->filt['id']))
131 131
       if (isset($this->filt['id']['*']) && count($this->filt['id']['*']) == 1)
132
-        return "Hamle\\Run::modelId(" .
133
-        Text::varToCode(current($this->filt['id']['*'])) .
132
+        return "Hamle\\Run::modelId(".
133
+        Text::varToCode(current($this->filt['id']['*'])).
134 134
         ",$limit)$sub";
135 135
       else
136
-        return "Hamle\\Run::modelTypeId(" .
137
-        Text::varToCode($this->filt['id']) . ",$limit)$sub";
136
+        return "Hamle\\Run::modelTypeId(".
137
+        Text::varToCode($this->filt['id']).",$limit)$sub";
138 138
     return "";
139 139
   }
140 140
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
    * @return Model
144 144
    */
145 145
   public function getOrCreateModel(Model $parent = null) {
146
-    if($this->scope instanceof Scope) {
146
+    if ($this->scope instanceof Scope) {
147 147
       $parent = $this->scope->getOrCreateModel();
148 148
     } elseif ($this->scope === true)
149 149
       $parent = \Seufert\Hamle\Scope::get(0);
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
           $this->sortlimit['limit'],
170 170
           $this->sortlimit['offset']
171 171
         );
172
-    if($this->sub)
172
+    if ($this->sub)
173 173
       return $this->sub->getOrCreateModel($parent)->current();
174
-    if(!$parent)
174
+    if (!$parent)
175 175
       throw new \RuntimeException('Unable to create model with no relation');
176 176
     return $parent->current();
177 177
   }
Please login to merge, or discard this patch.