Completed
Push — master ( 83bd2d...9517e2 )
by Arne
03:10
created

AbstractServiceFactoryContainer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getMap() 0 4 1
A register() 0 6 1
A has() 0 4 1
1
<?php
2
3
namespace Archivr;
4
5
abstract class AbstractServiceFactoryContainer
6
{
7
    protected $map;
8
9
    /**
10
     * @param callable[] $map
11
     */
12
    public function __construct(array $map = [])
13
    {
14
        $this->map = $map;
15
    }
16
17
    /**
18
     * @return callable[]
19
     */
20
    public function getMap(): array
21
    {
22
        return $this->map;
23
    }
24
25
    public function register(string $name, callable $factoryClosure): AbstractServiceFactoryContainer
26
    {
27
        $this->map[$name] = $factoryClosure;
28
29
        return $this;
30
    }
31
32
    public function has(string $name): bool
33
    {
34
        return isset($this->map[$name]);
35
    }
36
}
37