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

BaseToken   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 0
dl 0
loc 75
ccs 28
cts 28
cp 1
rs 10
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
getType() 0 1 ?
A __construct() 0 5 1
A getValue() 0 4 1
A getOriginalValue() 0 4 1
A getOffset() 0 4 1
A createNode() 0 4 1
A isOfType() 0 4 1
A isValue() 0 4 1
A isWhitespace() 0 4 1
A isMethod() 0 4 1
A isComma() 0 4 1
A isOperator() 0 4 1
A isLogical() 0 4 1
A isParenthesis() 0 4 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