AbstractSchema::getDefaultOptionValue()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4286
cc 3
eloc 8
nc 3
nop 3
1
<?php
2
3
namespace DoS\SettingsBundle\Schema;
4
5
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface as BaseSchemaInterface;
6
7
abstract class AbstractSchema implements BaseSchemaInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $namespace;
13
14
    /**
15
     * @param array  $options
16
     * @param string $steps
17
     * @param int    $default
18
     *
19
     * @return int
20
     */
21
    protected function getDefaultOptionValue(array $options, $steps, $default = 0)
22
    {
23
        $value = $options;
24
        $steps = explode('.', $steps);
25
26
        foreach ($steps as $step) {
27
            if (!array_key_exists($step, $value)) {
28
                return $default;
29
            }
30
31
            $value = $value[$step];
32
        }
33
34
        return $value;
35
    }
36
}
37