Completed
Push — master ( 5875b6...d65a71 )
by brian
01:43
created

ReferenceType::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
/**
4
 * @copyright   (c) 2019-present brian ridley
5
 * @author      brian ridley <[email protected]>
6
 * @license     http://opensource.org/licenses/MIT MIT
7
 */
8
9
namespace ptlis\SerializedDataEditor\Type;
10
11
use ptlis\SerializedDataEditor\Parser\Token;
12
13
/**
14
 * Class representing a serialized reference.
15
 *
16
 * TODO: How on earth can this be safely mutated?
17
 */
18
final class ReferenceType implements Type
19
{
20
    /** @var int */
21
    private $referenceIndex;
22
23
24 3
    public function __construct(int $referenceIndex)
25
    {
26 3
        $this->referenceIndex = $referenceIndex;
27 3
    }
28
29 1
    public function get(): int
30
    {
31 1
        return $this->referenceIndex;
32
    }
33
34 1
    public function set(int $referenceIndex): void
35
    {
36 1
        $this->referenceIndex = $referenceIndex;
37 1
    }
38
39 1
    public function __toString(): string
40
    {
41 1
        return Token::PREFIX_REFERENCE . ':' . $this->referenceIndex . ';';
42
    }
43
}