BaseString::__toString()   A
last analyzed

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 0
crap 1
1
<?php
2
3
namespace BaseValueObject\Scalar;
4
5
/**
6
 * Class BaseString
7
 * @package BaseValueObject\Scalar
8
 */
9
abstract class BaseString extends BaseScalar
10
{
11
    protected $value;
12
13
    /**
14
     * BaseString constructor.
15
     *
16
     * @param string $value
17
     */
18 27
    public function __construct(string $value)
19
    {
20 27
        $this->setValue($value);
21 15
    }
22
23
    /**
24
     * In this method you must add all the necessary validations.
25
     *
26
     * @param string $value
27
     * @return void
28
     */
29
    abstract protected function setValue(string $value): void;
30
31
    /**
32
     * {@inheritdoc}
33
     *
34
     * @return string
35
     */
36 15
    public function value(): string
37
    {
38 15
        return $this->value;
39
    }
40
41
    /**
42
     * @return string
43
     */
44 3
    public function __toString(): string
45
    {
46 3
        return $this->value();
47
    }
48
}
49