Completed
Push — master ( 7ac428...ba03ff )
by Karsten
10:44
created

StaticServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 6 1
A get() 0 4 1
A has() 0 4 2
1
<?php
2
/**
3
 * Created by gerk on 16.02.18 16:45
4
 */
5
6
namespace PeekAndPoke\Component\Slumber;
7
8
use Psr\Container\ContainerInterface;
9
10
/**
11
 *
12
 *
13
 * @author Karsten J. Gerber <[email protected]>
14
 */
15
class StaticServiceProvider implements ContainerInterface
16
{
17
    /**
18
     * @var array
19
     */
20
    private $instances = [];
21
22
    public function set($id, $instance): StaticServiceProvider
23
    {
24
        $this->instances[$id] = $instance;
25
26
        return $this;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function get($id)
33
    {
34
        return $this->instances[$id] ?? null;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function has($id)
41
    {
42
        return isset($this->instances[$id]) && $this->instances[$id] !== null;
43
    }
44
}
45