Completed
Push — 8.x-1.x ( 082f3b...0421f5 )
by
unknown
28:58 queued 09:33
created

ConfigurationAnnotation::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
ccs 5
cts 6
cp 0.8333
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
crap 3.0416
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 15
    public function __construct(array $values)
13
    {
14 15
        foreach ($values as $k => $v) {
15 14
            if (!method_exists($this, $name = 'set'.$k)) {
16
                throw new \RuntimeException(sprintf('Unknown key "%s" for annotation "@%s".', $k, get_class($this)));
17
            }
18
19 14
            $this->$name($v);
20
        }
21 15
    }
22
}
23