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

Instance::accepts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 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 5
    public function __construct(string $class)
14
    {
15 5
        $this->class = $class;
16 5
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 3
    public function accepts($value): bool
22
    {
23 3
        return $value instanceof $this->class;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 2
    public static function fromString(Str $value): Type
30
    {
31 2
        return new self((string) $value);
32
    }
33
}
34