Issues (30)

src/ContainerAliasBindingsTrait.php (2 issues)

1
<?php
2
3
namespace Nip\Container;
4
5
use League\Container\ServiceProvider\ServiceProviderInterface;
6
7
/**
8
 * Class ContainerAliasBindingsTrait
9
 * @package Nip\Container
10
 */
11
trait ContainerAliasBindingsTrait
12
{
13
    use ContainerAwareTrait {
14
        initContainer as initContainerTrait;
15
    }
16
17
    public function initContainer()
18
    {
19
        $this->initContainerTrait();
20
        $this->initContainerBindings();
21
    }
22
23
    protected function initContainerBindings()
24
    {
25
    }
26
27
    /**
28
     * @return ContainerInterface
29
     */
30
    public function generateContainer()
31
    {
32
        return Container::getInstance();
33
    }
34
35
    /**
36
     * @param $alias
37
     * @return mixed
38
     */
39
    public function get($alias)
40
    {
41
        return $this->getContainer()->get($alias);
42
    }
43
44
    /**
45
     * @param $alias
46
     * @return mixed
47
     */
48
    public function has($alias)
49
    {
50
        return $this->getContainer()->has($alias);
51
    }
52
53
    /**
54
     * @param $alias
55
     * @param null $concrete
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $concrete is correct as it would always require null to be passed?
Loading history...
56
     * @param bool $share
57
     */
58
    public function set($alias, $concrete = null, $share = false)
59
    {
60
        $this->getContainer()->set($alias, $concrete, $share);
61
    }
62
63
    /**
64
     * @param $alias
65
     * @param null $concrete
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $concrete is correct as it would always require null to be passed?
Loading history...
66
     */
67
    public function share($alias, $concrete = null)
68
    {
69
        $this->getContainer()->share($alias, $concrete);
70
    }
71
72
    /**
73
     * @param string|ServiceProviderInterface $provider
74
     * @return void
75
     */
76
    public function addServiceProvider($provider)
77
    {
78
        $this->getContainer()->addServiceProvider($provider);
79
    }
80
}
81