ScannerWithLocation   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 55
ccs 21
cts 24
cp 0.875
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getLine() 0 4 1
A getColumn() 0 8 2
A peek() 0 4 1
A next() 0 13 3
A eof() 0 4 1
A back() 0 4 1
1
<?php
2
3
namespace HansOtt\GraphQL\Shared;
4
5
use RuntimeException;
6
7
final class ScannerWithLocation implements Scanner
8
{
9
    private $scanner;
10
    private $line = 1;
11
    private $column = 0;
12
    private $nextCalledOnce = false;
13
14 111
    public function __construct(Scanner $scanner)
15
    {
16 111
        $this->scanner = $scanner;
17 111
    }
18
19 108
    public function getLine()
20
    {
21 108
        return $this->line;
22
    }
23
24 108
    public function getColumn()
25
    {
26 108
        if ($this->nextCalledOnce === false) {
27
            return 1;
28
        }
29
30 108
        return $this->column;
31
    }
32
33 108
    public function peek()
34
    {
35 108
        return $this->scanner->peek();
36
    }
37
38 108
    public function next()
39
    {
40 108
        $current = $this->scanner->next();
41 108
        $this->nextCalledOnce = true;
42 108
        if ($current === "\n" || $current === "\r") {
43 9
            $this->line++;
44 9
            $this->column = 1;
45 9
        } else {
46 108
            $this->column++;
47
        }
48
49 108
        return $current;
50
    }
51
52 111
    public function eof()
53
    {
54 111
        return $this->scanner->eof();
55
    }
56
57
    public function back()
58
    {
59
        throw new RuntimeException('Not implemented');
60
    }
61
}
62