Total Complexity | 7 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | final class CompoundBegin extends Token |
||
12 | { |
||
13 | /** |
||
14 | * Whether this compound should be lazy loaded. |
||
15 | * |
||
16 | * @var bool |
||
17 | */ |
||
18 | public bool $shouldLazyLoad = false; |
||
19 | |||
20 | /** |
||
21 | * Mutate the given state |
||
22 | * |
||
23 | * @param State $state |
||
24 | * @return void |
||
25 | */ |
||
26 | 136 | public function mutateState(State $state): void |
|
27 | { |
||
28 | 136 | $tree = $state->tree(); |
|
29 | |||
30 | 136 | if ($this->shouldLazyLoad = $this->shouldLazyLoad && $tree->depth() >= 0) { |
|
|
|||
31 | 9 | $state->expectedToken = $tree->inObject() ? Tokens::AFTER_OBJECT_VALUE : Tokens::AFTER_ARRAY_VALUE; |
|
32 | 9 | return; |
|
33 | } |
||
34 | |||
35 | 136 | $state->expectsKey = $beginsObject = $this->value == '{'; |
|
36 | 136 | $state->expectedToken = $beginsObject ? Tokens::AFTER_OBJECT_BEGIN : Tokens::AFTER_ARRAY_BEGIN; |
|
37 | 136 | $tree->deepen($beginsObject); |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * Set the token value |
||
42 | * |
||
43 | * @param string $value |
||
44 | * @return static |
||
45 | */ |
||
46 | 136 | public function setValue(string $value): static |
|
51 | } |
||
52 | |||
53 | /** |
||
54 | * Determine whether this token ends a JSON chunk |
||
55 | * |
||
56 | * @return bool |
||
57 | */ |
||
58 | 136 | public function endsChunk(): bool |
|
61 | } |
||
62 | } |
||
63 |