CreateSettingsContext   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 42
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A thereIsNothingRegisteredInStorageSystem() 0 5 1
A alreadyRegisteredKeyWithValue() 0 6 1
A youTryToCreateNewSettingNamedWithValue() 0 4 1
A theValueForKeyShouldBe() 0 4 1
1
<?php
2
3
namespace Galileo\SettingBundle\Features\Context;
4
5
use Behat\Behat\Context\Context;
6
use Galileo\SettingBundle\Lib\Application\SettingApplication;
7
use Galileo\SettingBundle\Lib\Infrastructure\Internal\InMemorySettingRepository;
8
use Galileo\SettingBundle\Lib\Model\ValueObject\Section;
9
10
class CreateSettingsContext implements Context
11
{
12
    /**
13
     * @var SettingApplication
14
     */
15
    private $settings;
16
17
    /**
18
     * @Given there is nothing registered in storage system
19
     */
20
    public function thereIsNothingRegisteredInStorageSystem()
21
    {
22
        $settingRepository = new InMemorySettingRepository([]);
23
        $this->settings = new SettingApplication($settingRepository);
24
    }
25
26
    /**
27
     * @Given there is already registered :key setting with :value value
28
     */
29
    public function alreadyRegisteredKeyWithValue($key, $value)
30
    {
31
        $this->settings = new SettingApplication(
32
            new InMemorySettingRepository([[$key, $value, Section::EMPTY_SECTION]])
33
        );
34
    }
35
36
    /**
37
     * @When you try to create new setting named :settingName with value :settingValue
38
     */
39
    public function youTryToCreateNewSettingNamedWithValue($settingName, $settingValue)
40
    {
41
        $this->settings->set($settingName, $settingValue);
42
    }
43
44
    /**
45
     * @Then the value for :key should be :value
46
     */
47
    public function theValueForKeyShouldBe($key, $value)
48
    {
49
        assert($value === $this->settings->get($key), 'Key value not the same as stored one');
50
    }
51
}
52