Completed
Push — master ( 163fd9...314ef3 )
by Neomerx
02:36
created

NestedGroup   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 40
ccs 13
cts 13
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parentGroup() 0 4 1
A getName() 0 8 3
A createGroup() 0 6 1
1
<?php namespace Limoncello\Core\Routing;
2
3
/**
4
 * Copyright 2015-2016 [email protected] (www.neomerx.com)
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Limoncello\Core\Contracts\Routing\GroupInterface;
20
21
/**
22
 * @package Limoncello\Core
23
 */
24
class NestedGroup extends BaseGroup
25
{
26
    /**
27
     * @param GroupInterface $parent
28
     */
29 12
    public function __construct(GroupInterface $parent)
30
    {
31 12
        $this->setParentGroup($parent);
32 12
    }
33
34
    /**
35
     * @return GroupInterface
36
     */
37 12
    public function parentGroup()
38
    {
39 12
        return parent::parentGroup();
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45 6
    public function getName()
46
    {
47 6
        $parentGroupName = $this->parentGroup()->getName();
48 6
        $selfName        = parent::getName();
49 6
        $result          = $parentGroupName !== null || $selfName !== null ? $parentGroupName . $selfName : null;
50
51 6
        return $result;
52
    }
53
54
    /**
55
     * @return NestedGroup
56
     */
57 2
    protected function createGroup()
58
    {
59 2
        $group = (new static($this))->setHasTrailSlash($this->hasTrailSlash());
60
61 2
        return $group;
62
    }
63
}
64