Completed
Push — master ( 3d13bd...bc1124 )
by brian
01:41
created

ArrayElementIntegerIndex::containsStringCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
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\TypeFragment;
10
11
use ptlis\SerializedDataEditor\Parser\Token;
12
use ptlis\SerializedDataEditor\Type\Type;
13
14
/**
15
 * Class representing a single element in an array, indexed by an integer.
16
 */
17
final class ArrayElementIntegerIndex implements ArrayElement
18
{
19
    /** @var int */
20
    private $index;
21
22
    /** @var Type */
23
    private $value;
24
25
26 20
    public function __construct(int $index, Type $value)
27
    {
28 20
        $this->index = $index;
29 20
        $this->value = $value;
30 20
    }
31
32 1
    public function getIndex(): int
33
    {
34 1
        return $this->index;
35
    }
36
37 1
    public function setIndex(int $index): void
38
    {
39 1
        $this->index = $index;
40 1
    }
41
42 1
    public function getValue(): Type
43
    {
44 1
        return $this->value;
45
    }
46
47 1
    public function setValue(Type $value): void
48
    {
49 1
        $this->value = $value;
50 1
    }
51
52 5
    public function containsStringCount(string $searchTerm): int
53
    {
54 5
        return $this->value->containsStringCount($searchTerm);
55
    }
56
57 3
    public function replaceString(string $searchTerm, string $replaceTerm): void
58
    {
59 3
        $this->value->replaceString($searchTerm, $replaceTerm);
60 3
    }
61
62 3
    public function __toString(): string
63
    {
64 3
        return Token::PREFIX_INTEGER . ':' . $this->index . ';' . $this->value;
65
    }
66
}