| Total Complexity | 8 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class NodeSetKey extends Node |
||
| 12 | { |
||
| 13 | 3 | public function __construct(string $nodeString, int $line) |
|
| 14 | { |
||
| 15 | 3 | parent::__construct($nodeString, $line); |
|
| 16 | 3 | $v = substr(trim($nodeString), 1); |
|
| 17 | 3 | if (!empty($v)) { |
|
| 18 | 3 | $value = NodeFactory::get($v, $line); |
|
| 19 | 3 | $value->indent = null; |
|
| 20 | 3 | $this->add($value); |
|
| 21 | } |
||
| 22 | 3 | } |
|
| 23 | |||
| 24 | /** |
||
| 25 | * @param object $parent The parent |
||
| 26 | * |
||
| 27 | * @throws \Exception if a problem occurs during serialisation (json format) of the key |
||
| 28 | */ |
||
| 29 | 1 | public function build(&$parent = null) |
|
| 30 | { |
||
| 31 | 1 | $built = is_null($this->value) ? null : $this->value->build(); |
|
| 32 | 1 | $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" '): $built; |
|
| 33 | 1 | $key = json_encode($stringKey, JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES); |
|
| 34 | 1 | if (empty($key)) throw new \Exception("Cant serialize complex key: ".var_export($this->value, true)); |
|
| 35 | 1 | $parent->{trim($key, '\'" ')} = null; |
|
| 36 | 1 | } |
|
| 37 | |||
| 38 | 1 | public function isAwaitingChild(Node $child):bool |
|
| 41 | } |
||
| 42 | } |