Completed
Push — master ( ffffde...8cec06 )
by Nico
01:31
created

BaseToken   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 0
loc 60
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

11 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 isOfType() 0 4 1
A createNode() 0 4 1
A isValue() 0 4 1
A isMethod() 0 4 1
A isComma() 0 4 1
A isWhitespace() 0 4 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 190
    public function isOfType(int $type): bool
50
    {
51 190
        return ($this->getType() | $type) === $type;
52
    }
53
54 144
    public function isValue(): bool
55
    {
56 144
        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 186
    public function isWhitespace(): bool
70
    {
71 186
        return false;
72
    }
73
}
74