Completed
Push — develop ( 523088...d9cee5 )
by Baptiste
01:42
created

Map   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 22
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A accepts() 0 8 3
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Compose\Definition\Argument\Type;
5
6
use Innmind\Compose\Definition\Argument\Type;
7
use Innmind\Immutable\MapInterface;
8
9
final class Map implements Type
10
{
11
    private $key;
12
    private $value;
13
14 2
    public function __construct(string $key, string $value)
15
    {
16 2
        $this->key = $key;
17 2
        $this->value = $value;
18 2
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 1
    public function accepts($value): bool
24
    {
25 1
        if (!$value instanceof MapInterface) {
26
            return false;
27
        }
28
29 1
        return (string) $value->keyType() === $this->key &&
30 1
            (string) $value->valueType() === $this->value;
31
    }
32
}
33