Code Duplication    Length = 23-24 lines in 3 locations

src/RouteModifier/RouteRequirePermission.php 1 location

@@ 8-31 (lines=24) @@
5
/**
6
 * @Annotation
7
 */
8
class RouteRequirePermission extends RouteRequirementsBase
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

src/RouteModifier/RouteTitle.php 1 location

@@ 8-30 (lines=23) @@
5
/**
6
 * @Annotation
7
 */
8
class RouteTitle extends RouteDefaultsBase
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
        $title = $values['value'];
23
24
        if (!is_string($title)) {
25
            throw new \RuntimeException('Title must be a string.');
26
        }
27
28
        parent::__construct(['_title' => $title]);
29
    }
30
}
31

src/RouteModifier/RouteTitleCallback.php 1 location

@@ 8-30 (lines=23) @@
5
/**
6
 * @Annotation
7
 */
8
class RouteTitleCallback extends RouteDefaultsBase
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('Title callback must be specified.');
20
        }
21
22
        $titleCallback = $values['value'];
23
24
        if (!is_callable($titleCallback)) {
25
            throw new \RuntimeException('Title callback must be callable.');
26
        }
27
28
        parent::__construct(['_title_callback' => $titleCallback]);
29
    }
30
}
31