Completed
Push — master ( a5cd41...696772 )
by stéphane
04:51
created
yaml/Builder.php 1 patch
Braces   +29 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
      */
30 30
     private static function build(object $node, &$parent = null)
31 31
     {
32
-        if ($node instanceof NodeList) return self::buildNodeList($node, $parent);
32
+        if ($node instanceof NodeList) {
33
+            return self::buildNodeList($node, $parent);
34
+        }
33 35
         return self::buildNode($node, $parent);
34 36
     }
35 37
 
@@ -84,7 +86,9 @@  discard block
 block discarded – undo
84 86
             } else {
85 87
                 $tmp = $node->getPhpValue();
86 88
             }
87
-            if ($type === Y::REF_DEF) self::$_root->addReference($identifier, $tmp);
89
+            if ($type === Y::REF_DEF) {
90
+                self::$_root->addReference($identifier, $tmp);
91
+            }
88 92
             return self::$_root->getReference($identifier);
89 93
         }
90 94
         $typesActions = [Y::COMMENT   => 'buildComment',
@@ -169,10 +173,14 @@  discard block
 block discarded – undo
169 173
         }
170 174
         $_root->value->setIteratorMode(NodeList::IT_MODE_DELETE);
171 175
         foreach ($_root->value as $child) {
172
-            if ($child->type & Y::DOC_START) $totalDocStart++;
176
+            if ($child->type & Y::DOC_START) {
177
+                $totalDocStart++;
178
+            }
173 179
             //if 0 or 1 DOC_START = we are still in first document
174 180
             $currentDoc = $totalDocStart > 1 ? $totalDocStart - 1 : 0;
175
-            if (!isset($documents[$currentDoc])) $documents[$currentDoc] = new NodeList();
181
+            if (!isset($documents[$currentDoc])) {
182
+                $documents[$currentDoc] = new NodeList();
183
+            }
176 184
             $documents[$currentDoc]->push($child);
177 185
         }
178 186
         $content = array_map([self::class, 'buildDocument'], $documents, array_keys($documents));
@@ -242,9 +250,15 @@  discard block
 block discarded – undo
242 250
                 $lines[] = $prefix.$child->value;
243 251
             }
244 252
         }
245
-        if ($type & Y::RAW)         return implode('',   $lines);
246
-        if ($type & Y::LITT)        return implode("\n", $lines);
247
-        if ($type & Y::LITT_FOLDED) return implode(' ',  $lines);
253
+        if ($type & Y::RAW) {
254
+            return implode('',   $lines);
255
+        }
256
+        if ($type & Y::LITT) {
257
+            return implode("\n", $lines);
258
+        }
259
+        if ($type & Y::LITT_FOLDED) {
260
+            return implode(' ',  $lines);
261
+        }
248 262
         return '';
249 263
     }
250 264
 
@@ -259,8 +273,9 @@  discard block
 block discarded – undo
259 273
     private function buildSetKey(Node $node, $parent):void
260 274
     {
261 275
         $key = json_encode(self::build($node->value, $parent), JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES);
262
-        if (empty($key))
263
-        throw new \Exception("Cant serialize complex key: ".var_export($node->value, true), 1);
276
+        if (empty($key)) {
277
+                throw new \Exception("Cant serialize complex key: ".var_export($node->value, true), 1);
278
+        }
264 279
         $parent->{$key} = null;
265 280
     }
266 281
 
@@ -299,8 +314,11 @@  discard block
 block discarded – undo
299 314
         }
300 315
         //TODO: have somewhere a list of common tags and their treatment
301 316
         if (in_array($node->identifier, ['!binary', '!str'])) {
302
-            if ($node->value->value instanceof NodeList) $node->value->value->type = Y::RAW;
303
-            else $node->value->type = Y::RAW;
317
+            if ($node->value->value instanceof NodeList) {
318
+                $node->value->value->type = Y::RAW;
319
+            } else {
320
+                $node->value->type = Y::RAW;
321
+            }
304 322
         }
305 323
         $val = is_null($node->value) ? null : self::build(/** @scrutinizer ignore-type */ $node->value, $node);
306 324
         return new Tag($node->identifier, $val);
Please login to merge, or discard this patch.