Passed
Branch v2 (aaaa8e)
by Brent
03:38
created

DynamicFactory::removeRule()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Stitcher;
4
5
abstract class DynamicFactory
6
{
7
    private $rules = [];
8
9
    public function setRule(string $class, callable $callback): DynamicFactory
10
    {
11
        $this->rules[$class] = $callback;
12
13
        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
    protected function getRules(): array
26
    {
27
        return $this->rules;
28
    }
29
}
30