@@ -23,10 +23,13 @@ discard block |
||
| 23 | 23 | final public static function get($nodeString = null, $line = 0):NodeGeneric |
| 24 | 24 | { |
| 25 | 25 | $trimmed = ltrim($nodeString); |
| 26 | - if ($trimmed === '') return new Nodes\Blank($nodeString, $line); |
|
| 27 | - elseif (substr($trimmed, 0, 3) === '...') return new Nodes\DocEnd($nodeString, $line); |
|
| 28 | - elseif ((bool) preg_match(Regex::KEY, $trimmed, $matches)) return new Nodes\Key($nodeString, $line, $matches); |
|
| 29 | - else { |
|
| 26 | + if ($trimmed === '') { |
|
| 27 | + return new Nodes\Blank($nodeString, $line); |
|
| 28 | + } elseif (substr($trimmed, 0, 3) === '...') { |
|
| 29 | + return new Nodes\DocEnd($nodeString, $line); |
|
| 30 | + } elseif ((bool) preg_match(Regex::KEY, $trimmed, $matches)) { |
|
| 31 | + return new Nodes\Key($nodeString, $line, $matches); |
|
| 32 | + } else { |
|
| 30 | 33 | $first = $trimmed[0]; |
| 31 | 34 | $stringGroups = ['-', '>|' , '"\'', "#%" , "{[" , ":?" , '*&!']; |
| 32 | 35 | $methodGroups = ['Hyphen','Literal','Quoted','Special','Compact','SetElement','NodeAction']; |
@@ -105,10 +108,13 @@ discard block |
||
| 105 | 108 | final private static function onCompact(string $first, string $nodeString, int $line):NodeGeneric |
| 106 | 109 | { |
| 107 | 110 | json_decode($nodeString, false, 512, self::JSON_OPTIONS); |
| 108 | - if (json_last_error() === \JSON_ERROR_NONE) return new Nodes\JSON($nodeString, $line); |
|
| 109 | - elseif ((bool) preg_match(Regex::MAPPING, trim($nodeString))) return new Nodes\CompactMapping($nodeString, $line); |
|
| 110 | - elseif ((bool) preg_match(Regex::SEQUENCE, trim($nodeString))) return new Nodes\CompactSequence($nodeString, $line); |
|
| 111 | - else { |
|
| 111 | + if (json_last_error() === \JSON_ERROR_NONE) { |
|
| 112 | + return new Nodes\JSON($nodeString, $line); |
|
| 113 | + } elseif ((bool) preg_match(Regex::MAPPING, trim($nodeString))) { |
|
| 114 | + return new Nodes\CompactMapping($nodeString, $line); |
|
| 115 | + } elseif ((bool) preg_match(Regex::SEQUENCE, trim($nodeString))) { |
|
| 116 | + return new Nodes\CompactSequence($nodeString, $line); |
|
| 117 | + } else { |
|
| 112 | 118 | return new Nodes\Partial($nodeString, $line); |
| 113 | 119 | } |
| 114 | 120 | } |
@@ -123,9 +129,11 @@ discard block |
||
| 123 | 129 | */ |
| 124 | 130 | final private static function onHyphen(string $first, string $nodeString, int $line):NodeGeneric |
| 125 | 131 | { |
| 126 | - if (substr($nodeString, 0, 3) === '---') return new Nodes\DocStart($nodeString, $line); |
|
| 127 | - elseif ((bool) preg_match(Regex::ITEM, ltrim($nodeString))) return new Nodes\Item($nodeString, $line); |
|
| 128 | - else { |
|
| 132 | + if (substr($nodeString, 0, 3) === '---') { |
|
| 133 | + return new Nodes\DocStart($nodeString, $line); |
|
| 134 | + } elseif ((bool) preg_match(Regex::ITEM, ltrim($nodeString))) { |
|
| 135 | + return new Nodes\Item($nodeString, $line); |
|
| 136 | + } else { |
|
| 129 | 137 | return new Nodes\Scalar($nodeString, $line); |
| 130 | 138 | } |
| 131 | 139 | } |