RouteGroups::name()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace MinasRouter\Router;
4
5
use MinasRouter\Router\RouteCollection;
6
use MinasRouter\Router\Middlewares\MiddlewareCollection;
7
8
class RouteGroups
9
{
10
    /** @var string */
11
    public $name;
12
13
    /** @var string */
14
    public $prefix;
15
16
    /** @var string */
17
    public $namespace;
18
19
    /** @var object */
20
    public $middlewares;
21
22
    /** @var object */
23
    protected $collection;
24
25
    public function __construct(RouteCollection $collection)
26
    {
27
        $this->collection = $collection;
28
    }
29
30
    /**
31
     * Set a namespace for the group.
32
     * 
33
     * @return \MinasRouter\Router\RouteGroups
34
     */
35
    public function namespace($namespace): RouteGroups
36
    {
37
        $this->namespace = $namespace;
38
39
        return $this;
40
    }
41
42
    /**
43
     * Set a prefix for the group.
44
     * 
45
     * @return \MinasRouter\Router\RouteGroups
46
     */
47
    public function prefix($prefix): RouteGroups
48
    {
49
        $this->prefix = $prefix;
50
51
        return $this;
52
    }
53
54
    /**
55
     * Set a name for the group.
56
     * 
57
     * @return \MinasRouter\Router\RouteGroups
58
     */
59
    public function name($name): RouteGroups
60
    {
61
        $this->name = $name;
62
63
        return $this;
64
    }
65
66
    /**
67
     * Set a middlewares for the group.
68
     * 
69
     * @return \MinasRouter\Router\RouteGroups
70
     */
71
    public function middlewares($middlewares): RouteGroups
72
    {
73
        $this->middlewares = new MiddlewareCollection($middlewares);
74
75
        return $this;
76
    }
77
78
    public function group(\Closure $routeGroups)
79
    {
80
        call_user_func($routeGroups);
81
82
        return $this->collection->defineGroup();
83
    }
84
}
85