Completed
Pull Request — 8.x-1.x (#7)
by
unknown
65:17
created

RouteMethod   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 29
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 4
1
<?php
2
3
namespace Drupal\controller_annotations\RouteModifier;
4
5
/**
6
 * @Annotation
7
 */
8
class RouteMethod extends RouteMethodsBase
9
{
10
11
    /**
12
     * @param array $values
13
     *
14
     * @throws \RuntimeException
15
     */
16
    public function __construct(array $values)
17
    {
18
        if (!isset($values['value'])) {
19
            throw new \RuntimeException('Route method(s) must be specified.');
20
        }
21
22
        $value = $values['value'];
23
24
        if (is_string($value)) {
25
            $methods = [$value];
26
        }
27
        elseif (is_array($value)) {
28
            $methods = $value;
29
        }
30
        else {
31
            throw new \RuntimeException('Route methods must be string or array.');
32
        }
33
34
        parent::__construct($methods);
35
    }
36
}
37