GlobParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 11 3
1
<?php
2
namespace Xiag\Rql\Parser\ValueParser;
3
4
use Xiag\Rql\Parser\Token;
5
use Xiag\Rql\Parser\TokenStream;
6
use Xiag\Rql\Parser\SubParserInterface;
7
use Xiag\Rql\Parser\Glob;
8
9
class GlobParser implements SubParserInterface
10
{
11
    /**
12
     * @var array Allowed types to convert to glob
13
     */
14
    protected static $allowedTypes = [
15
        Token::T_INTEGER,
16
        Token::T_FLOAT,
17
        Token::T_STRING,
18
        Token::T_DATE,
19
    ];
20
21
    /**
22
     * @inheritdoc
23
     */
24 32
    public function parse(TokenStream $tokenStream)
25
    {
26 32
        if ($tokenStream->test(Token::T_GLOB)) {
27 15
            return new Glob($tokenStream->next()->getValue());
28
        }
29
30 17
        if ($tokenStream->nextIf(Token::T_TYPE, 'glob')) {
31 1
            $tokenStream->expect(Token::T_COLON);
32 1
        }
33 17
        return new Glob(Glob::encode($tokenStream->expect(static::$allowedTypes)->getValue()));
34
    }
35
}
36