SubLexerChain   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addSubLexer() 0 5 1
A getTokenAt() 0 11 3
1
<?php
2
namespace Xiag\Rql\Parser;
3
4
class SubLexerChain implements SubLexerInterface
5
{
6
    /**
7
     * @var SubLexerInterface[]
8
     */
9
    protected $subLexers = [];
10
11
    /**
12
     * @param SubLexerInterface $subLexer
13
     * @return $this
14
     */
15 85
    public function addSubLexer(SubLexerInterface $subLexer)
16
    {
17 85
        $this->subLexers[] = $subLexer;
18 85
        return $this;
19
    }
20
21
    /**
22
     * @inheritdoc
23
     */
24 85
    public function getTokenAt($code, $cursor)
25
    {
26 85
        foreach ($this->subLexers as $subLexer) {
27 85
            $token = $subLexer->getTokenAt($code, $cursor);
28 85
            if ($token !== null) {
29 85
                return $token;
30
            }
31 85
        }
32
33 2
        return null;
34
    }
35
}
36