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

Service   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
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