Completed
Push — master ( f0cf24...757a85 )
by Dmitrij
9s
created

IsInstantiable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 12 2
A __construct() 0 3 1
1
<?php
2
3
namespace HotRodCli\Checkers\Container;
4
5
use HotRodCli\Checkers\BaseChecker;
6
use HotRodCli\Checkers\BaseStatus;
7
8
class IsInstantiable extends BaseChecker
9
{
10
    protected $class;
11
12
    public function __construct(string $class)
13
    {
14
        $this->class = $class;
15
    }
16
17
    public function check(BaseStatus $status)
18
    {
19
        $reflector = new \ReflectionClass($this->class);
20
21
        if (!$reflector->isInstantiable()) {
22
            $status->setFailedWith(IsInstantiable::class);
23
            $status->setStatus(false);
24
25
            return $status;
26
        }
27
28
        return $this->next($status);
29
    }
30
}
31