Completed
Push — develop ( 2c61cc...b9b8dc )
by Baptiste
02:42
created

Sequence   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A accepts() 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 7
    public static function fromString(Str $value): Type
29
    {
30 7
        if ((string) $value !== 'sequence') {
31 5
            throw new ValueNotSupported((string) $value);
32
        }
33
34 2
        return new self;
35
    }
36
}
37