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

IsAlreadyExists::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace HotRodCli\Checkers\Container;
4
5
use HotRodCli\Checkers\BaseChecker;
6
use HotRodCli\Checkers\BaseStatus;
7
8
class IsAlreadyExists extends BaseChecker
9
{
10
    protected $registry;
11
12
    protected $class;
13
14
    public function __construct(array $registry, string $class)
15
    {
16
        $this->registry = $registry;
17
        $this->class = $class;
18
    }
19
20
    public function check(BaseStatus $status)
21
    {
22
        if (array_key_exists($this->class, $this->registry)) {
23
            $status->setFailedWith(IsAlreadyExists::class);
24
            $status->setStatus(false);
25
26
            return $status;
27
        }
28
29
        return $this->next($status);
30
    }
31
}
32