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

StaticServiceProvider::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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