ConfigurationAnnotation::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Drupal\controller_annotations\Configuration;
4
5
/**
6
 * Base configuration annotation.
7
 *
8
 * @author Johannes M. Schmitt <[email protected]>
9
 */
10
abstract class ConfigurationAnnotation implements ConfigurationInterface
11
{
12 44
    public function __construct(array $values)
13
    {
14 44
        foreach ($values as $k => $v) {
15 36
            if (!method_exists($this, $name = 'set'.$k)) {
16 1
                throw new \RuntimeException(sprintf('Unknown key "%s" for annotation "@%s".', $k, get_class($this)));
17
            }
18
19 35
            $this->$name($v);
20
        }
21 43
    }
22
}
23