Completed
Push — master ( 8cec06...5dae2f )
by Nico
01:28
created

BaseToken::isValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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 198
    public function getValue()
30
    {
31 198
        return $this->value;
32
    }
33
34 94
    final public function getOriginalValue()
35
    {
36 94
        return $this->value;
37
    }
38
39 154
    public function getOffset(): int
40
    {
41 154
        return $this->offset;
42
    }
43
44 208
    public function createNode(TokenStream $tokenStream): self
45
    {
46 208
        return $this;
47
    }
48
49 214
    public function isOfType(int $type): bool
50
    {
51 214
        return ($this->getType() | $type) === $type;
52
    }
53
54 210
    public function isValue(): bool
55
    {
56 210
        return $this->isOfType(TokenType::VALUE | TokenType::INT_VALUE);
57
    }
58
59 186
    public function isMethod(): bool
60
    {
61 186
        return $this->isOfType(TokenType::METHOD);
62
    }
63
64 144
    public function isComma(): bool
65
    {
66 144
        return $this->isOfType(TokenType::COMMA);
67
    }
68
69 182
    public function isOperator(): bool
70
    {
71 182
        return $this->isOfType(TokenType::OPERATOR);
72
    }
73
74 48
    public function isLogical(): bool
75
    {
76 48
        return $this->isOfType(TokenType::LOGICAL);
77
    }
78
79 30
    public function isParenthesis(): bool
80
    {
81 30
        return $this->isOfType(TokenType::PARENTHESIS);
82
    }
83
84 210
    public function isWhitespace(): bool
85
    {
86 210
        return false;
87
    }
88
}
89