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

CompoundBegin   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 13
ccs 4
cts 4
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A mutateState() 0 5 2
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