Passed
Push — develop ( ec1e42...80559e )
by Brent
03:22
created

DynamicFactory::removeRule()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 0
cts 4
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Stitcher;
4
5
abstract class DynamicFactory
6
{
7
    private $rules = [];
8
9 31
    public function setRule(string $class, callable $callback): DynamicFactory
10
    {
11 31
        $this->rules[$class] = $callback;
12
13 31
        return $this;
14
    }
15
16
    public function removeRule(string $class): DynamicFactory
17
    {
18
        if (isset($this->rules[$class])) {
19
            unset($this->rules[$class]);
20
        }
21
22
        return $this;
23
    }
24
25 25
    protected function getRules(): array
26
    {
27 25
        return $this->rules;
28
    }
29
}
30