Completed
Push — master ( a26615...ffffde )
by Nico
01:34
created

BaseToken::getLine()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @license     http://opensource.org/licenses/mit-license.php MIT
7
 * @link        https://github.com/nicoSWD
8
 * @author      Nicolas Oelgart <[email protected]>
9
 */
10
namespace nicoSWD\Rule\TokenStream\Token;
11
12
use nicoSWD\Rule\TokenStream\TokenStream;
13
14
abstract class BaseToken
15
{
16
    /** @var mixed */
17
    protected $value;
18
    /** @var int */
19
    protected $offset = 0;
20
21
    abstract public function getType(): int;
22
23 228
    public function __construct($value, int $offset = 0)
24
    {
25 228
        $this->value = $value;
26 228
        $this->offset = $offset;
27 228
    }
28
29 196
    public function getValue()
30
    {
31 196
        return $this->value;
32
    }
33
34 98
    final public function getOriginalValue()
35
    {
36 98
        return $this->value;
37
    }
38
39 150
    public function getOffset(): int
40
    {
41 150
        return $this->offset;
42
    }
43
44 186
    public function isWhitespace(): bool
45
    {
46 186
        return false;
47
    }
48
49 190
    public function isOfType(int $type): bool
50
    {
51 190
        return ($this->getType() | $type) === $type;
52
    }
53
54 206
    public function createNode(TokenStream $tokenStream): self
55
    {
56 206
        return $this;
57
    }
58
}
59