AbstractConfigurable   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 0
dl 0
loc 21
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B configure() 0 18 9
1
<?php
2
3
namespace CSSPrites;
4
5
abstract class AbstractConfigurable
6
{
7 21
    public function configure(array $config = [])
8
    {
9 21
        if (is_array($config) && array_key_exists('filename', $config)) {
10 18
            $config['filepath']  = isset($config['filepath']) && is_string($config['filepath']) ? $config['filepath'] : '.';
11 18
            $config['filepath'] .= '/';
12 18
            $config['filepath'] .= isset($config['filename']) && is_string($config['filename']) ? $config['filename'] : 'sprite.png';
13 18
            unset($config['filename']);
14 18
        }
15
16 21
        foreach ($config as $key => $value) {
17 21
            if (!property_exists($this, $key)) {
18 3
                throw new \Exception('Undefined configuration property "'.$key.'"');
19
            }
20 18
            $this->$key = $value;
21 18
        }
22
23 18
        return $this;
24
    }
25
}
26