SplString   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 30
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 4 1
1
<?php
2
3
/**
4
 * Part of SplTypes package.
5
 *
6
 * (c) Adrien Loyant <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Ducks\Component\SplTypes;
15
16
/**
17
 * The SplString class is used to enforce strong typing of the string type.
18
 *
19
 * @extends SplType<string>
20
 *
21
 * @psalm-api
22
 */
23
class SplString extends SplType
24
{
25
    /**
26
     * @var string
27
     *
28
     * @psalm-suppress InvalidClassConstantType
29
     */
30
    // phpcs:ignore Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase
31
    protected const __default = '';
32
33
    /**
34
     * {@inheritdoc}
35
     *
36
     * @param string $initial_value
37
     *
38
     * @SuppressWarnings(PHPMD.CamelCaseParameterName)
39
     * @SuppressWarnings(PHPMD.CamelCaseVariableName)
40
     */
41 6
    public function __construct(string $initial_value = self::__default)
42
    {
43 6
        parent::__construct($initial_value);
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49 4
    final public function &__invoke(): string
50
    {
51
        /** @var string */
52 4
        return $this->__default;
53
    }
54
}
55