Passed
Push — master ( 8b770c...945f9e )
by Chris
03:04
created
php/hamle/Tag.php 1 patch
Braces   +33 added lines, -21 removed lines patch added patch discarded remove patch
@@ -76,9 +76,10 @@  discard block
 block discarded – undo
76 76
       }
77 77
       array_shift($path);
78 78
     }
79
-    foreach ($this->tags as $tag)
80
-      if ($found = $tag->find($path))
81
-        $list = array_merge($list, $found);
79
+    foreach ($this->tags as $tag) {
80
+          if ($found = $tag->find($path))
81
+        $list = array_merge($list, $found);
82
+    }
82 83
     return $list;
83 84
   }
84 85
 
@@ -90,7 +91,9 @@  discard block
 block discarded – undo
90 91
    */
91 92
   function replace($path, Tag $newTag) {
92 93
     if ($this->compare($path[0])) {
93
-      if (count($path) == 1) return $newTag;
94
+      if (count($path) == 1) {
95
+        return $newTag;
96
+      }
94 97
       array_shift($path);
95 98
     }
96 99
     foreach ($this->tags as $k => $tag) {
@@ -103,19 +106,23 @@  discard block
 block discarded – undo
103 106
   }
104 107
 
105 108
   function addSnipContent($contentTag, &$tagArray = array(), $key = 0) {
106
-    foreach ($this->tags as $k => $tag)
107
-      $tag->addSnipContent($contentTag, $this->tags, $k);
109
+    foreach ($this->tags as $k => $tag) {
110
+          $tag->addSnipContent($contentTag, $this->tags, $k);
111
+    }
108 112
   }
109 113
 
110 114
   function compare($tic) {
111
-    if (isset($tic['type']) && $this->type != $tic['type'])
112
-      return false;
115
+    if (isset($tic['type']) && $this->type != $tic['type']) {
116
+          return false;
117
+    }
113 118
     if (isset($tic['id']) &&
114 119
         !(isset($this->opt['id']) && $tic['id'] == $this->opt['id'])
115
-    )
116
-      return false;
117
-    if (array_diff($tic['class'] ?? [], $this->opt['class'] ?? []))
118
-      return false;
120
+    ) {
121
+          return false;
122
+    }
123
+    if (array_diff($tic['class'] ?? [], $this->opt['class'] ?? [])) {
124
+          return false;
125
+    }
119 126
     return true;
120 127
   }
121 128
 
@@ -125,10 +132,11 @@  discard block
 block discarded – undo
125 132
    * @param string $mode Mode to add child [append|prepend]
126 133
    */
127 134
   function addChild(Tag $tag, $mode = "append") {
128
-    if ($mode == "prepend")
129
-      array_unshift($this->tags, $tag);
130
-    else
131
-      $this->tags[] = $tag;
135
+    if ($mode == "prepend") {
136
+          array_unshift($this->tags, $tag);
137
+    } else {
138
+          $this->tags[] = $tag;
139
+    }
132 140
   }
133 141
 
134 142
   /**
@@ -142,9 +150,12 @@  discard block
 block discarded – undo
142 150
     $ind = $minify ? '' : str_pad('', $indent);
143 151
     $oneliner = (!(count($this->content) > 1 || $this->tags));
144 152
     $out = $ind . $this->renderStTag() . ($oneliner || $minify ? '' : "\n");
145
-    if ($this->content) $out .= $this->renderContent($ind, $oneliner || $minify);
146
-    foreach ($this->tags as $tag)
147
-      $out .= $tag->render($indent + self::INDENT_SIZE, $minify);
153
+    if ($this->content) {
154
+      $out .= $this->renderContent($ind, $oneliner || $minify);
155
+    }
156
+    foreach ($this->tags as $tag) {
157
+          $out .= $tag->render($indent + self::INDENT_SIZE, $minify);
158
+    }
148 159
     $out .= ($minify || $oneliner ? '' : $ind) . $this->renderEnTag() . ($minify ? '' : "\n");
149 160
     return $out;
150 161
   }
@@ -158,8 +169,9 @@  discard block
 block discarded – undo
158 169
    */
159 170
   function renderContent($pad = "", $oneliner = false) {
160 171
     $out = "";
161
-    foreach ($this->content as $c)
162
-      $out .= ($oneliner ? '' : $pad) . $c . ($oneliner ? '' : "\n");
172
+    foreach ($this->content as $c) {
173
+          $out .= ($oneliner ? '' : $pad) . $c . ($oneliner ? '' : "\n");
174
+    }
163 175
     return $out;
164 176
   }
165 177
 
Please login to merge, or discard this patch.
php/hamle/Tag/Snippet.php 1 patch
Braces   +29 added lines, -18 removed lines patch added patch discarded remove patch
@@ -32,25 +32,33 @@  discard block
 block discarded – undo
32 32
 
33 33
   function __construct($params) {
34 34
     parent::__construct();
35
-    if (!preg_match('/^(append|content|prepend|replace)(?: (.*))?$/', $params, $m))
36
-      throw new Hamle\Exception\ParseError("Unable to parse Snippet($params)");
35
+    if (!preg_match('/^(append|content|prepend|replace)(?: (.*))?$/', $params, $m)) {
36
+          throw new Hamle\Exception\ParseError("Unable to parse Snippet($params)");
37
+    }
37 38
     $this->type = $m[1];
38
-    if (isset($m[2]))
39
-      $this->path = explode(" ", $m[2]);
40
-    else
41
-      $this->path = array();
42
-    foreach ($this->path as $k => $v)
43
-      $this->path[$k] = self::decodeClassId($v);
39
+    if (isset($m[2])) {
40
+          $this->path = explode(" ", $m[2]);
41
+    } else {
42
+          $this->path = array();
43
+    }
44
+    foreach ($this->path as $k => $v) {
45
+          $this->path[$k] = self::decodeClassId($v);
46
+    }
44 47
   }
45 48
 
46 49
   static function decodeClassId($s) {
47 50
     $out = $m = array();
48
-    if(preg_match('/^[a-zA-Z0-9\_]+/', $s, $m))
49
-      $out['type'] = $m[0];
51
+    if(preg_match('/^[a-zA-Z0-9\_]+/', $s, $m)) {
52
+          $out['type'] = $m[0];
53
+    }
50 54
     preg_match_all('/[#\.][a-zA-Z0-9\-\_]+/m', $s, $m);
51
-    if (isset($m[0])) foreach ($m[0] as $ss) {
55
+    if (isset($m[0])) {
56
+      foreach ($m[0] as $ss) {
52 57
       if ($ss[0] === "#") $out['id'] = substr($ss, 1);
53
-      if ($ss[0] === ".") $out['class'][] = substr($ss, 1);
58
+    }
59
+      if ($ss[0] === ".") {
60
+        $out['class'][] = substr($ss, 1);
61
+      }
54 62
     }
55 63
     return $out;
56 64
   }
@@ -62,21 +70,24 @@  discard block
 block discarded – undo
62 70
   function addSnipContent($contentTag, &$tagArray = array(), $key = 0) {
63 71
     if ($this->type == "content") {
64 72
       $tagArray[$key] = $contentTag;
65
-    } else
66
-      parent::addSnipContent($contentTag, $tagArray, $key);
73
+    } else {
74
+          parent::addSnipContent($contentTag, $tagArray, $key);
75
+    }
67 76
   }
68 77
 
69 78
   function apply(Hamle\Tag $rootTag) {
70 79
     if ($this->type == "append" or $this->type == "prepend") {
71 80
       $matchTags = $rootTag->find($this->path);
72
-      foreach ($matchTags as $tag)
73
-        foreach ($this->tags as $t) {
81
+      foreach ($matchTags as $tag) {
82
+              foreach ($this->tags as $t) {
74 83
           $tag->addChild($t, $this->type);
84
+      }
75 85
         }
76 86
     } elseif ($this->type == "replace") {
77 87
       $rootTag->replace($this->path, $this);
78
-    } else
79
-      throw new Hamle\Exception\ParseError("Cant Apply snippet to document '{$this->type}'");
88
+    } else {
89
+          throw new Hamle\Exception\ParseError("Cant Apply snippet to document '{$this->type}'");
90
+    }
80 91
   }
81 92
 
82 93
 }
Please login to merge, or discard this patch.