SettingApplication::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 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