@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class NodeFactory |
21 | 21 | { |
22 | - private const JSON_OPTIONS = \JSON_PARTIAL_OUTPUT_ON_ERROR | \JSON_UNESCAPED_SLASHES; |
|
22 | + private const JSON_OPTIONS = \JSON_PARTIAL_OUTPUT_ON_ERROR|\JSON_UNESCAPED_SLASHES; |
|
23 | 23 | |
24 | 24 | final public static function get(string $nodeString, int $line = 0, bool $debug = false): NodeGeneric |
25 | 25 | { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $match => new Nodes\Key($nodeString, $line, $matches), |
33 | 33 | default => self::onCharacter($trimmed[0], $nodeString, $line) |
34 | 34 | }; |
35 | - if ($debug) echo $line . ":" . get_class($node) . "\n"; |
|
35 | + if ($debug) echo $line.":".get_class($node)."\n"; |
|
36 | 36 | return $node; |
37 | 37 | } |
38 | 38 |
@@ -32,7 +32,9 @@ |
||
32 | 32 | $match => new Nodes\Key($nodeString, $line, $matches), |
33 | 33 | default => self::onCharacter($trimmed[0], $nodeString, $line) |
34 | 34 | }; |
35 | - if ($debug) echo $line . ":" . get_class($node) . "\n"; |
|
35 | + if ($debug) { |
|
36 | + echo $line . ":" . get_class($node) . "\n"; |
|
37 | + } |
|
36 | 38 | return $node; |
37 | 39 | } |
38 | 40 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | { |
29 | 29 | if ($dataType === \INF) return '.inf'; |
30 | 30 | if ($dataType === -\INF) return '-.inf'; |
31 | - $precision = "%." . $this->dumper->floatPrecision . "F"; |
|
31 | + $precision = "%.".$this->dumper->floatPrecision."F"; |
|
32 | 32 | switch (gettype($dataType)) { |
33 | 33 | case 'boolean': |
34 | 34 | return $dataType ? 'true' : 'false'; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | $pairs = ['']; |
96 | 96 | $realIndent = $indent + Dumper::INDENT; |
97 | - if($isRoot) { |
|
97 | + if ($isRoot) { |
|
98 | 98 | $pairs = []; |
99 | 99 | $realIndent = 0; |
100 | 100 | } |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | { |
111 | 111 | $pairs = []; |
112 | 112 | foreach ($o as $key => $value) { |
113 | - $pairs[] = "$key: " . $this->dumper->dump($value, 0, true, false); |
|
113 | + $pairs[] = "$key: ".$this->dumper->dump($value, 0, true, false); |
|
114 | 114 | } |
115 | - return '{'. implode(', ', $pairs) . '}'; |
|
115 | + return '{'.implode(', ', $pairs).'}'; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | 119 | public function dumpArray(array $a, int $indent, bool $isCompact = false, $isRoot = false): string |
120 | 120 | { |
121 | - if(isset($a[0]) && $a[0] instanceof YamlObject) { |
|
121 | + if (isset($a[0]) && $a[0] instanceof YamlObject) { |
|
122 | 122 | return $this->dumper->dumpMultiDoc($a); |
123 | 123 | } |
124 | 124 | if (array_keys($a) !== range(0, count($a) - 1)) { |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | $pairs = ['']; |
135 | 135 | $realIndent = $indent + Dumper::INDENT; |
136 | - if($isRoot) { |
|
136 | + if ($isRoot) { |
|
137 | 137 | $pairs = []; |
138 | 138 | $realIndent = 0; |
139 | 139 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | foreach ($a as $value) { |
152 | 152 | $pairs[] = $this->dumper->dump($value, $indent, true); |
153 | 153 | } |
154 | - return '[' . implode(', ', $pairs) . ']'; |
|
154 | + return '['.implode(', ', $pairs).']'; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | $separator = "\n"; |
187 | 187 | $isCompact = $obj->value instanceof Compact; |
188 | 188 | if (is_scalar($obj->value) || $isCompact) { |
189 | - $separator = ' '; |
|
189 | + $separator = ' '; |
|
190 | 190 | } |
191 | - return ($obj->tagName) . $separator . $this->dumper->dump($obj->value, $indent, $isCompact); |
|
191 | + return ($obj->tagName).$separator.$this->dumper->dump($obj->value, $indent, $isCompact); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 |
@@ -26,8 +26,12 @@ |
||
26 | 26 | |
27 | 27 | public function dumpScalar($dataType): string |
28 | 28 | { |
29 | - if ($dataType === \INF) return '.inf'; |
|
30 | - if ($dataType === -\INF) return '-.inf'; |
|
29 | + if ($dataType === \INF) { |
|
30 | + return '.inf'; |
|
31 | + } |
|
32 | + if ($dataType === -\INF) { |
|
33 | + return '-.inf'; |
|
34 | + } |
|
31 | 35 | $precision = "%." . $this->dumper->floatPrecision . "F"; |
32 | 36 | switch (gettype($dataType)) { |
33 | 37 | case 'boolean': |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function toString($dataType, ?int $options = null): string |
53 | 53 | { |
54 | - if (empty($dataType)) throw new \Exception(self::class . ": No content to convert to Yaml"); |
|
54 | + if (empty($dataType)) throw new \Exception(self::class.": No content to convert to Yaml"); |
|
55 | 55 | if (is_scalar($dataType)) { |
56 | - return "--- " . $this->handler->dumpScalar($dataType) . PHP_EOL; |
|
56 | + return "--- ".$this->handler->dumpScalar($dataType).PHP_EOL; |
|
57 | 57 | } |
58 | 58 | return $this->dump($dataType, 0, false, true); |
59 | 59 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | foreach ($arrayOfYamlObject as $yamlObject) { |
96 | 96 | $docs[] = $this->dumpYamlObject($yamlObject); |
97 | 97 | } |
98 | - return "---\n" . implode("\n---\n", $docs); |
|
98 | + return "---\n".implode("\n---\n", $docs); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $pairs = []; |
115 | 115 | if (count($properties) === 0) { |
116 | 116 | return $this->handler->dumpArray($obj->getArrayCopy(), 0, false, true); |
117 | - }else { |
|
117 | + } else { |
|
118 | 118 | return $this->handler->dumpObject($obj, 0, false, true); |
119 | 119 | } |
120 | 120 | } |
@@ -51,7 +51,9 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function toString($dataType, ?int $options = null): string |
53 | 53 | { |
54 | - if (empty($dataType)) throw new \Exception(self::class . ": No content to convert to Yaml"); |
|
54 | + if (empty($dataType)) { |
|
55 | + throw new \Exception(self::class . ": No content to convert to Yaml"); |
|
56 | + } |
|
55 | 57 | if (is_scalar($dataType)) { |
56 | 58 | return "--- " . $this->handler->dumpScalar($dataType) . PHP_EOL; |
57 | 59 | } |
@@ -114,7 +116,7 @@ discard block |
||
114 | 116 | $pairs = []; |
115 | 117 | if (count($properties) === 0) { |
116 | 118 | return $this->handler->dumpArray($obj->getArrayCopy(), 0, false, true); |
117 | - }else { |
|
119 | + } else { |
|
118 | 120 | return $this->handler->dumpObject($obj, 0, false, true); |
119 | 121 | } |
120 | 122 | } |