Passed
Branch feature/first-release (43e0cc)
by Andrea Marco
10:48
created

CompoundBegin::mutateState()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Cerbero\JsonParser\Tokens;
4
5
use Cerbero\JsonParser\State;
6
7
/**
8
 * The token that begins compound data (JSON arrays or objects).
9
 *
10
 */
11
final class CompoundBegin extends Token
12
{
13
    /**
14
     * Mutate the given state
15
     *
16
     * @param State $state
17
     * @return void
18
     */
19 126
    public function mutateState(State $state): void
20
    {
21 126
        $state->expectsKey = $beginsObject = $this->value == '{';
22 126
        $state->expectedToken = $beginsObject ? Tokens::AFTER_OBJECT_BEGIN : Tokens::AFTER_ARRAY_BEGIN;
23 126
        $state->tree()->deepen($beginsObject);
24
    }
25
}
26