Total Complexity | 7 |
Total Lines | 48 |
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 | 357 | public function mutateState(State $state): void |
|
27 | { |
||
28 | 357 | if ($this->shouldLazyLoad = $this->shouldLazyLoad && $state->tree->depth() >= 0) { |
|
|
|||
29 | 34 | $state->expectedToken = $state->tree->inObject() ? Tokens::AFTER_OBJECT_VALUE : Tokens::AFTER_ARRAY_VALUE; |
|
30 | 34 | return; |
|
31 | } |
||
32 | |||
33 | 357 | $state->expectsKey = $beginsObject = $this->value == '{'; |
|
34 | 357 | $state->expectedToken = $beginsObject ? Tokens::AFTER_OBJECT_BEGIN : Tokens::AFTER_ARRAY_BEGIN; |
|
35 | 357 | $state->tree->deepen($beginsObject); |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * Set the token value |
||
40 | * |
||
41 | * @param string $value |
||
42 | * @return static |
||
43 | */ |
||
44 | 357 | public function setValue(string $value): static |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Determine whether this token ends a JSON chunk |
||
53 | * |
||
54 | * @return bool |
||
55 | */ |
||
56 | 357 | public function endsChunk(): bool |
|
59 | } |
||
60 | } |
||
61 |