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

IsAlreadyExists::check()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
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