Completed
Push — master ( 82eb41...4f6b0a )
by Alexander
03:49
created

PunctuationSubLexer   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 7
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 25
ccs 15
cts 15
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getTokenAt() 0 19 7
1
<?php
2
namespace Xiag\Rql\Parser\SubLexer;
3
4
use Xiag\Rql\Parser\Token;
5
use Xiag\Rql\Parser\SubLexerInterface;
6
7
class PunctuationSubLexer implements SubLexerInterface
8
{
9
    /**
10
     * @inheritdoc
11
     */
12 85
    public function getTokenAt($code, $cursor)
13
    {
14 85
        $test = substr($code, $cursor, 1);
15 85
        if ($test === '&') {
16 29
            return new Token(Token::T_AMPERSAND, $test, $cursor, $cursor + 1);
17 85
        } elseif ($test === '|') {
18 6
            return new Token(Token::T_VERTICAL_BAR, $test, $cursor, $cursor + 1);
19 85
        } elseif ($test === ',') {
20 76
            return new Token(Token::T_COMMA, $test, $cursor, $cursor + 1);
21 85
        } elseif ($test === '(') {
22 82
            return new Token(Token::T_OPEN_PARENTHESIS, $test, $cursor, $cursor + 1);
23 85
        } elseif ($test === ')') {
24 78
            return new Token(Token::T_CLOSE_PARENTHESIS, $test, $cursor, $cursor + 1);
25 85
        } elseif ($test === ':') {
26 9
            return new Token(Token::T_COLON, $test, $cursor, $cursor + 1);
27
        } else {
28 85
            return null;
29
        }
30
    }
31
}
32