ReferenceType   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
cbo 0
dl 0
loc 37
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 4 1
A set() 0 4 1
A containsStringCount() 0 5 1
A replaceString() 0 4 1
A __toString() 0 4 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 5
    public function __construct(int $referenceIndex)
25
    {
26 5
        $this->referenceIndex = $referenceIndex;
27 5
    }
28
29 2
    public function get(): int
30
    {
31 2
        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 containsStringCount(string $searchTerm): int
40
    {
41
        // TODO: Properly handle this - should it return the value for the referred-to component?
42 1
        return 0;
43
    }
44
45 1
    public function replaceString(string $searchTerm, string $replaceTerm): void
46
    {
47
        // TODO: Properly handle this - should it return the value for the referred-to component?
48 1
    }
49
50 1
    public function __toString(): string
51
    {
52 1
        return Token::PREFIX_REFERENCE . ':' . $this->referenceIndex . ';';
53
    }
54
}