Passed
Push — master ( 39dd55...cb4ea4 )
by Mikael
02:08
created

DIFactoryConfig::__construct()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4.0218

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 8
cts 9
cp 0.8889
rs 9.2
cc 4
eloc 7
nc 3
nop 1
crap 4.0218
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
13
{
14
    use ConfigureTrait;
15
16
17
18
   /**
19
     * Constructor creating a set of services included into this DI container.
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 2
        }
31 2
    }
32
}
33