Passed
Push — master ( d8e937...c675bb )
by Edward
10:57
created

IntegerAttribute::asString()   A

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\Lexer\Runtime\Token;
6
7
use Remorhaz\Lexer\Runtime\Unicode\StringInterface;
8
9
/**
10
 * @psalm-immutable
11
 */
12
final class IntegerAttribute implements AttributeInterface
13
{
14
15
    /**
16
     * @var int
17
     */
18
    private $value;
19
20
    /**
21
     * @param int $value
22
     */
23 3
    public function __construct(int $value)
24
    {
25 3
        $this->value = $value;
26 3
    }
27
28
    /**
29
     * @return StringInterface
30
     * @psalm-pure
31
     */
32 1
    public function asString(): StringInterface
33
    {
34 1
        throw new Exception\WrongAttributeTypeException($this->value, 'Unicode string');
35
    }
36
37
    /**
38
     * @return bool
39
     * @psalm-pure
40
     */
41 1
    public function asBoolean(): bool
42
    {
43 1
        throw new Exception\WrongAttributeTypeException($this->value, 'boolean');
44
    }
45
46
    /**
47
     * @return int
48
     * @psalm-pure
49
     */
50 1
    public function asInteger(): int
51
    {
52 1
        return $this->value;
53
    }
54
}
55