Completed
Push — 8.x-1.x ( 0421f5...0df7dc )
by
unknown
25:14
created

ConfigurationAnnotation::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

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.4285
c 0
b 0
f 0
cc 3
eloc 5
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 21
    public function __construct(array $values)
13
    {
14 21
        foreach ($values as $k => $v) {
15 20
            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 19
            $this->$name($v);
20
        }
21 20
    }
22
}
23