AbstractServiceProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PrettyBx\Support\Base;
6
7
use PrettyBx\Support\Contracts\ServiceProviderContract;
8
9
abstract class AbstractServiceProvider implements ServiceProviderContract
10
{
11
    /**
12
     * @var array $singletons
13
     */
14
    protected $singletons = [];
15
16
    /**
17
     * @var \Illuminate\Container\Container $container
18
     */
19
    protected $container;
20
21
    public function __construct()
22
    {
23
        $this->container = container();
24
25
        $this->bindSinletons();
26
    }
27
28
    /**
29
     * @inheritDoc
30
     */
31
    public function register(): void
32
    {
33
34
    }
35
36
    /**
37
     * bindSinletons.
38
     *
39
     * @access	protected
40
     * @return	void
41
     */
42
    protected function bindSinletons(): void
43
    {
44
        foreach ($this->singletons as $id => $implementation) {
45
            if (is_string($id)) {
46
                $this->container->singleton($id, $implementation);
47
            } else {
48
                $this->container->singleton($implementation);
49
            }
50
        }
51
    }
52
}
53