Instance   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A fromString() 0 3 1
A accepts() 0 3 1
A __toString() 0 3 1
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\Str;
8
9
final class Instance implements Type
10
{
11
    private $class;
12
13 29
    public function __construct(string $class)
14
    {
15 29
        $this->class = $class;
16 29
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 9
    public function accepts($value): bool
22
    {
23 9
        return $value instanceof $this->class;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 9
    public static function fromString(Str $value): Type
30
    {
31 9
        return new self((string) $value);
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 14
    public function __toString(): string
38
    {
39 14
        return $this->class;
40
    }
41
}
42