Completed
Push — master ( 5b71e4...f50740 )
by stéphane
02:26
created
yaml/Loader.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,9 +78,13 @@  discard block
 block discarded – undo
78 78
     public function parse($strContent = null)
79 79
     {
80 80
         $source = $this->content;
81
-        if (is_null($source)) $source = preg_split("/([^\n\r]+)/um", $strContent, 0, PREG_SPLIT_DELIM_CAPTURE);
81
+        if (is_null($source)) {
82
+            $source = preg_split("/([^\n\r]+)/um", $strContent, 0, PREG_SPLIT_DELIM_CAPTURE);
83
+        }
82 84
         //TODO : be more permissive on $strContent values
83
-        if (!is_array($source)) throw new \Exception(self::EXCEPTION_LINE_SPLIT);
85
+        if (!is_array($source)) {
86
+            throw new \Exception(self::EXCEPTION_LINE_SPLIT);
87
+        }
84 88
         $previous = $root = new Node();
85 89
         $emptyLines = [];
86 90
         $specialTypes = Y\LITTERALS|Y\BLANK;
@@ -108,7 +112,9 @@  discard block
 block discarded – undo
108 112
                         case -1: $previous->getParent($n->indent)->add($n);break;
109 113
                         case 0: $previous->getParent()->add($n);break;
110 114
                         default:
111
-                            if ($this->onDeepestType($n, $previous, $lineString)) continue 2;
115
+                            if ($this->onDeepestType($n, $previous, $lineString)) {
116
+                                continue 2;
117
+                            }
112 118
                             $previous->add($n);
113 119
                     }
114 120
                     $previous = $n;
@@ -147,8 +153,12 @@  discard block
 block discarded – undo
147 153
             }
148 154
         }
149 155
         if ($n->type & Y\BLANK) {
150
-            if ($previous->type & Y\SCALAR) $emptyLines[] = $n->setParent($previous->getParent());
151
-            if ($deepest->type & Y\LITTERALS) $emptyLines[] = $n->setParent($deepest);
156
+            if ($previous->type & Y\SCALAR) {
157
+                $emptyLines[] = $n->setParent($previous->getParent());
158
+            }
159
+            if ($deepest->type & Y\LITTERALS) {
160
+                $emptyLines[] = $n->setParent($deepest);
161
+            }
152 162
             return true;
153 163
         }
154 164
         return false;
Please login to merge, or discard this patch.
yaml/Dumper.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function __construct(int $options = null)
23 23
     {
24
-        if (is_int($options)) self::$options = $options;
24
+        if (is_int($options)) {
25
+            self::$options = $options;
26
+        }
25 27
     }
26 28
 
27 29
     /**
@@ -36,7 +38,9 @@  discard block
 block discarded – undo
36 38
      */
37 39
     public static function toString($dataType, int $options = null):string
38 40
     {
39
-        if (is_null($dataType)) throw new \Exception(self::class.": No content to convert to Yaml", 1);
41
+        if (is_null($dataType)) {
42
+            throw new \Exception(self::class.": No content to convert to Yaml", 1);
43
+        }
40 44
         self::$options = is_int($options) ? $options : self::OPTIONS;
41 45
         self::$result = new DLL;
42 46
         self::$result->setIteratorMode(DLL::IT_MODE_FIFO|DLL::IT_MODE_DELETE);
@@ -74,8 +78,12 @@  discard block
 block discarded – undo
74 78
         if (is_scalar($dataType)) {
75 79
             switch (gettype($dataType)) {
76 80
                 case 'boolean': return $dataType ? 'true' : 'false';
77
-                case 'float': if (is_infinite((float) $dataType)) return $dataType > 0 ? '.inf' : '-.inf';
78
-                case 'double': if (is_nan((float) $dataType)) return '.nan';
81
+                case 'float': if (is_infinite((float) $dataType)) {
82
+                    return $dataType > 0 ? '.inf' : '-.inf';
83
+                }
84
+                case 'double': if (is_nan((float) $dataType)) {
85
+                    return '.nan';
86
+                }
79 87
                 default:
80 88
                     return $dataType;
81 89
             }
Please login to merge, or discard this patch.
yaml/Builder.php 1 patch
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 
19 19
     private static function build(object $node, &$parent = null)
20 20
     {
21
-        if ($node instanceof NodeList) return self::buildNodeList($node, $parent);
21
+        if ($node instanceof NodeList) {
22
+            return self::buildNodeList($node, $parent);
23
+        }
22 24
         return self::buildNode($node, $parent);
23 25
     }
24 26
 
@@ -60,12 +62,15 @@  discard block
 block discarded – undo
60 62
             case Y\REF_DEF: //fall through
61 63
             case Y\REF_CALL://TODO: self::build returns what ?
62 64
                 $tmp = is_object($value) ? self::build($value, $parent) : $node->getPhpValue();
63
-                if ($type === Y\REF_DEF) self::$_root->addReference($identifier, $tmp);
65
+                if ($type === Y\REF_DEF) {
66
+                    self::$_root->addReference($identifier, $tmp);
67
+                }
64 68
                 return self::$_root->getReference($identifier);
65 69
             case Y\SET_KEY:
66 70
                 $key = json_encode(self::build($value, $parent), JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES);
67
-                if (empty($key))
68
-                    throw new \Exception("Cant serialize complex key: ".var_export($value, true), 1);
71
+                if (empty($key)) {
72
+                                    throw new \Exception("Cant serialize complex key: ".var_export($value, true), 1);
73
+                }
69 74
                 $parent->{$key} = null;
70 75
                 return;
71 76
             case Y\SET_VALUE:
@@ -84,8 +89,11 @@  discard block
 block discarded – undo
84 89
                     $parent->addTag($identifier); return;
85 90
                 } else {//TODO: have somewhere a list of common tags and their treatment
86 91
                     if (in_array($identifier, ['!binary', '!str'])) {
87
-                        if ($value->value instanceof NodeList) $value->value->type = Y\RAW;
88
-                        else $value->type = Y\RAW;
92
+                        if ($value->value instanceof NodeList) {
93
+                            $value->value->type = Y\RAW;
94
+                        } else {
95
+                            $value->type = Y\RAW;
96
+                        }
89 97
                     }
90 98
                     $val = is_null($value) ? null : self::build($value, $node);
91 99
                     return new Tag($identifier, $val);
@@ -153,10 +161,14 @@  discard block
 block discarded – undo
153 161
         }
154 162
         $_root->value->setIteratorMode(NodeList::IT_MODE_DELETE);
155 163
         foreach ($_root->value as $child) {
156
-            if ($child->type & Y\DOC_START) $totalDocStart++;
164
+            if ($child->type & Y\DOC_START) {
165
+                $totalDocStart++;
166
+            }
157 167
             //if 0 or 1 DOC_START = we are still in first document
158 168
             $currentDoc = $totalDocStart > 1 ? $totalDocStart - 1 : 0;
159
-            if (!isset($documents[$currentDoc])) $documents[$currentDoc] = new NodeList();
169
+            if (!isset($documents[$currentDoc])) {
170
+                $documents[$currentDoc] = new NodeList();
171
+            }
160 172
             $documents[$currentDoc]->push($child);
161 173
         }
162 174
         // $_debug >= 2 && var_dump($documents);//var_dump($documents);die("documents");
Please login to merge, or discard this patch.