Passed
Push — master ( e1468a...94992f )
by Mikael
02:31
created

DIFactoryConfig   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 25
ccs 9
cts 12
cp 0.75
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 15 6
1
<?php
2
3
namespace Anax\DI;
4
5
use \Anax\Configure\ConfigureInterface;
6
use \Anax\Configure\ConfigureTrait;
7
8
/**
9
 * DI factory class creating a set of default services by loading
10
 * them from a configuration file.
11
 */
12
class DIFactoryConfig extends DI implements ConfigureInterface, DIInterface
13
{
14
    use ConfigureTrait;
15
16
17
18
   /**
19
     * Constructor creating a set of services from a configuration file.
20
     */
21 2
    public function __construct($configFile)
22
    {
23 2
        $this->configure($configFile);
24 2
        foreach ($this->config["services"] as $name => $service) {
25 2
            if (isset($service["shared"]) && $service["shared"]) {
26 2
                $this->setShared($name, $service["callback"]);
27 2
            } else {
28
                $this->set($name, $service["callback"]);
29
            }
30
31 2
            if (isset($service["active"]) && $service["active"]) {
32
                $this->get($name);
33
            }
34 2
        }
35 2
    }
36
}
37