BaseToken::isOperator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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\Parser\Exception\ParserException;
11
use nicoSWD\Rule\TokenStream\TokenStream;
12
13
abstract class BaseToken
14
{
15
    abstract public function getType(): int;
16
17
    public function __construct(
18
        private mixed $value,
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

18
        /** @scrutinizer ignore-unused */ private mixed $value,

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
        private int $offset = 0
0 ignored issues
show
Unused Code introduced by
The parameter $offset is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

19
        /** @scrutinizer ignore-unused */ private int $offset = 0

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
    ) {
21
    }
22 336
23
    public function getValue(): mixed
24 336
    {
25 336
        return $this->value;
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist on nicoSWD\Rule\TokenStream\Token\BaseToken. Did you maybe forget to declare it?
Loading history...
26 336
    }
27
28 286
    final public function getOriginalValue(): mixed
29
    {
30 286
        return $this->value;
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist on nicoSWD\Rule\TokenStream\Token\BaseToken. Did you maybe forget to declare it?
Loading history...
31
    }
32
33 154
    public function getOffset(): int
34
    {
35 154
        return $this->offset;
0 ignored issues
show
Bug Best Practice introduced by
The property offset does not exist on nicoSWD\Rule\TokenStream\Token\BaseToken. Did you maybe forget to declare it?
Loading history...
36
    }
37
38 90
    /** @throws ParserException */
39
    public function createNode(TokenStream $tokenStream): self
0 ignored issues
show
Unused Code introduced by
The parameter $tokenStream is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function createNode(/** @scrutinizer ignore-unused */ TokenStream $tokenStream): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40 90
    {
41
        return $this;
42
    }
43
44 238
    public function isOfType(int $type): bool
45
    {
46 238
        return ($this->getType() | $type) === $type;
47
    }
48
49 270
    public function isValue(): bool
50
    {
51 270
        return $this->isOfType(TokenType::VALUE | TokenType::INT_VALUE);
52
    }
53
54 174
    public function isWhitespace(): bool
55
    {
56 174
        return $this->isOfType(TokenType::SPACE | TokenType::COMMENT);
57
    }
58
59 252
    public function isMethod(): bool
60
    {
61 252
        return $this->isOfType(TokenType::METHOD);
62
    }
63
64 248
    public function isComma(): bool
65
    {
66 248
        return $this->isOfType(TokenType::COMMA);
67
    }
68
69 174
    public function isOperator(): bool
70
    {
71 174
        return $this->isOfType(TokenType::OPERATOR);
72
    }
73
74 2
    public function isLogical(): bool
75
    {
76 2
        return $this->isOfType(TokenType::LOGICAL);
77
    }
78
79 2
    public function isParenthesis(): bool
80
    {
81 2
        return $this->isOfType(TokenType::PARENTHESIS);
82
    }
83
}
84