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

DynamicFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setRule() 0 6 1
A removeRule() 0 8 2
A getRules() 0 4 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