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

Map::accepts()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.072

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 3
nop 1
crap 3.072
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