Passed
Pull Request — master (#13)
by Matthew
01:38
created

Service::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Dynamic\Salsify\Model;
4
5
use SilverStripe\Core\Config\Config;
6
use SilverStripe\Core\Config\Configurable;
7
use SilverStripe\Core\Extensible;
8
use SilverStripe\Core\Injector\Injectable;
9
10
/**
11
 * Class Service
12
 * @package Dynamic\Salsify\Model
13
 *
14
 * @mixin Configurable
15
 * @mixin Extensible
16
 * @mixin Injectable
17
 */
18
abstract class Service
19
{
20
    use Configurable;
21
    use Extensible;
22
    use Injectable;
23
24
    /**
25
     * @var string
26
     */
27
    protected $importerKey;
28
29
    /**
30
     * @var string
31
     */
32
    protected $serviceName;
33
34
35
    public function __construct($importerKey)
36
    {
37
        $this->importerKey = $importerKey;
38
        $this->serviceName = static::class . '.' . $this->importerKey;
39
40
        $serviceConfig = Config::inst()->get($this->serviceName);
41
        foreach ($serviceConfig as $key => $value) {
42
            $this->config()->set($key, $value);
43
        }
44
    }
45
}
46