| Total Complexity | 6 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | final class Map implements Type |
||
| 16 | { |
||
| 17 | private const PATTERN = '~^map<(?<key>.+), ?(?<value>.+)>$~'; |
||
| 18 | private $key; |
||
| 19 | private $value; |
||
| 20 | |||
| 21 | 4 | public function __construct(string $key, string $value) |
|
| 25 | 4 | } |
|
| 26 | |||
| 27 | /** |
||
| 28 | * {@inheritdoc} |
||
| 29 | */ |
||
| 30 | 2 | public function accepts($value): bool |
|
| 31 | { |
||
| 32 | 2 | if (!$value instanceof MapInterface) { |
|
| 33 | 1 | return false; |
|
| 34 | } |
||
| 35 | |||
| 36 | 2 | return (string) $value->keyType() === $this->key && |
|
| 37 | 2 | (string) $value->valueType() === $this->value; |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritdoc} |
||
| 42 | */ |
||
| 43 | 8 | public static function fromString(Str $value): Type |
|
| 54 | ); |
||
| 55 | } |
||
| 57 |