Sequence   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A accepts() 0 3 1
A __toString() 0 3 1
A fromString() 0 7 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose\Definition\Argument\Type;
5
6
use Innmind\Compose\{
7
    Definition\Argument\Type,
8
    Exception\ValueNotSupported
9
};
10
use Innmind\Immutable\{
11
    SequenceInterface,
12
    Str
13
};
14
15
final class Sequence implements Type
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 2
    public function accepts($value): bool
21
    {
22 2
        return $value instanceof SequenceInterface;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 14
    public static function fromString(Str $value): Type
29
    {
30 14
        if ((string) $value !== 'sequence') {
31 12
            throw new ValueNotSupported((string) $value);
32
        }
33
34 2
        return new self;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function __toString(): string
41
    {
42 1
        return 'sequence';
43
    }
44
}
45