Completed
Push — master ( 6ebc1f...137f9b )
by Kamil
02:37
created

SettingApplication   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 36
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 6 1
A section() 0 4 1
A set() 0 5 1
1
<?php
2
3
namespace Galileo\SettingBundle\Lib\Application;
4
5
use Galileo\SettingBundle\Lib\Model\SectionBagInterface;
6
use Galileo\SettingBundle\Lib\Model\SectionQuery;
7
use Galileo\SettingBundle\Lib\Model\SettingRepositoryInterface;
8
use Galileo\SettingBundle\Lib\Model\ValueObject\Section;
9
10
class SettingApplication implements SectionBagInterface
11
{
12
    private $settingRepository;
13
14 7
    public function __construct(SettingRepositoryInterface $settingRepository)
15
    {
16 7
        $this->settingRepository = $settingRepository;
17 7
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 6
    public function get($settingKey, $defaultValue = null)
23
    {
24 6
        $sectionQuery = new SectionQuery($this->settingRepository, Section::blank());
25
26 6
        return $sectionQuery->get($settingKey, $defaultValue);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function section($name)
33
    {
34
        return new SectionQuery($this->settingRepository, new Section($name));
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 2
    public function set($keyName, $valueString)
41
    {
42 2
        $sectionQuery = new SectionQuery($this->settingRepository, Section::blank());
43 2
        $sectionQuery->set($keyName, $valueString);
44 2
    }
45
}
46