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

DynamicFactory::getRules()   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 0
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