Completed
Pull Request — 8.x-1.x (#7)
by
unknown
106:26 queued 41:26
created

RouteRequirePermission::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 14
loc 14
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
1
<?php
2
3
namespace Drupal\controller_annotations\RouteModifier;
4
5
/**
6
 * @Annotation
7
 */
8 View Code Duplication
class RouteRequirePermission extends RouteRequirementsBase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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('Permission name must be specified.');
20
        }
21
22
        $permissionName = $values['value'];
23
24
        if (!is_string($permissionName)) {
25
            throw new \RuntimeException('Permission name must be a string.');
26
        }
27
28
        parent::__construct(['_permission' => $permissionName]);
29
    }
30
31
}
32