Completed
Push — master ( 09b8d4...001e48 )
by Nico
01:48
created

BaseToken::isOperator()   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 declare(strict_types=1);
2
3
/**
4
 * @license     http://opensource.org/licenses/mit-license.php MIT
5
 * @link        https://github.com/nicoSWD
6
 * @author      Nicolas Oelgart <[email protected]>
7
 */
8
namespace nicoSWD\Rule\TokenStream\Token;
9
10
use nicoSWD\Rule\TokenStream\TokenStream;
11
12
abstract class BaseToken
13
{
14
    /** @var mixed */
15
    private $value;
16
    /** @var int */
17
    private $offset = 0;
18
19
    abstract public function getType(): int;
20
21 266
    public function __construct($value, int $offset = 0)
22
    {
23 266
        $this->value = $value;
24 266
        $this->offset = $offset;
25 266
    }
26
27 216
    public function getValue()
28
    {
29 216
        return $this->value;
30
    }
31
32 96
    final public function getOriginalValue()
33
    {
34 96
        return $this->value;
35
    }
36
37 56
    public function getOffset(): int
38
    {
39 56
        return $this->offset;
40
    }
41
42 210
    public function createNode(TokenStream $tokenStream): self
43
    {
44 210
        return $this;
45
    }
46
47 208
    public function isOfType(int $type): bool
48
    {
49 208
        return ($this->getType() | $type) === $type;
50
    }
51
52 146
    public function isValue(): bool
53
    {
54 146
        return $this->isOfType(TokenType::VALUE | TokenType::INT_VALUE);
55
    }
56
57 190
    public function isWhitespace(): bool
58
    {
59 190
        return $this->isOfType(TokenType::SPACE | TokenType::COMMENT);
60
    }
61
62 190
    public function isMethod(): bool
63
    {
64 190
        return $this->isOfType(TokenType::METHOD);
65
    }
66
67 146
    public function isComma(): bool
68
    {
69 146
        return $this->isOfType(TokenType::COMMA);
70
    }
71
72 2
    public function isOperator(): bool
73
    {
74 2
        return $this->isOfType(TokenType::OPERATOR);
75
    }
76
77 2
    public function isLogical(): bool
78
    {
79 2
        return $this->isOfType(TokenType::LOGICAL);
80
    }
81
82 2
    public function isParenthesis(): bool
83
    {
84 2
        return $this->isOfType(TokenType::PARENTHESIS);
85
    }
86
}
87