Di   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 7
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 73
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setContainer() 0 5 1
A getContainer() 0 4 1
A setService() 0 5 1
A getService() 0 6 2
A getServices() 0 4 1
1
<?php
2
/**
3
 * Jaeger
4
 *
5
 * @copyright	Copyright (c) 2015-2016, mithra62
6
 * @link		http://jaeger-app.com
7
 * @version		1.0
8
 * @filesource 	./Di.php
9
 */
10
namespace JaegerApp; 
11
12
use Pimple\Container;
13
14
/**
15
 * Jaeger - Dependency Injection Object
16
 *
17
 * Wrapper for a simple database interface
18
 *
19
 * @package Database
20
 * @author Eric Lamb <[email protected]>
21
 */
22
class Di
23
{
24
    /**
25
     * The Pimple DI Container object
26
     *
27
     * @var \Pimple\Container
28
     */
29
    protected $container = null;
30
    
31
    public function __construct()
32
    {
33
        $container = new Container();
34
        $this->setContainer($container);
35
    }
36
37
    /**
38
     * Sets the DI Container object
39
     * 
40
     * @param \Pimple\Container $container            
41
     */
42
    public function setContainer(\Pimple\Container $container)
43
    {
44
        $this->container = $container;
45
        return $this;
46
    }
47
48
    /**
49
     * Returns an instance of the DI Container
50
     * 
51
     * @return \Pimple\Container
52
     */
53
    public function getContainer()
54
    {
55
        return $this->container;
56
    }
57
58
    /**
59
     * Sets a new service outside of the bootstrap object
60
     * 
61
     * @param string $name
62
     *            The name of the new service
63
     * @param \Closure $function
64
     *            The Closure to execute when the service is called
65
     * @return \JaegerApp\Bootstrap
66
     */
67
    public function setService($name, \Closure $function)
68
    {
69
        $this->container[$name] = $function;
70
        return $this;
71
    }
72
    
73
    /**
74
     * Returns a single service
75
     * @param string $service The name of the service we want
76
     * @return \Pimple\Container
77
     */
78
    public function getService($service)
79
    {
80
        if(isset($this->container[$service])) {
81
            return $this->container[$service];
82
        }
83
    }
84
    
85
    /**
86
     * Sets up and returns all the objects we'll use
87
     *
88
     * @return \Pimple\Container
89
     */
90
    public function getServices()
91
    {
92
        return $this->container;
93
    }
94
}