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

StringType::__construct()   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 string value.
15
 */
16
final class StringType implements Type
17
{
18
    /** @var string */
19
    private $value;
20
21
22 26
    public function __construct(string $value)
23
    {
24 26
        $this->value = $value;
25 26
    }
26
27 1
    public function get(): string
28
    {
29 1
        return $this->value;
30
    }
31
32 1
    public function set(string $value): void
33
    {
34 1
        $this->value = $value;
35 1
    }
36
37 8
    public function __toString(): string
38
    {
39 8
        return Token::PREFIX_STRING . ':' . strlen($this->value) . ':"' . $this->value . '";';
40
    }
41
}