StringType::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace drupol\valuewrapper\Type;
6
7
use drupol\valuewrapper\Contract\Stringable;
8
9
/**
10
 * Class StringType.
11
 */
12
class StringType extends TypeValue implements Stringable
13
{
14
    /**
15
     * StringType constructor.
16
     *
17
     * @param string $value
18
     */
19 13
    public function __construct(string $value)
20
    {
21 13
        parent::__construct($value);
22 13
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 1
    public function __toArray(): array
28
    {
29 1
        return (false === $split = str_split($this->value())) ?
30
            [] :
31 1
            $split;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1
    public function __toString(): string
38
    {
39 1
        return (string) $this->value();
40
    }
41
}
42