AbstractSchema   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 0
cbo 0
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDefaultOptionValue() 0 15 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