Failed Conditions
Push — experimental/3.1 ( cb54a4...028283 )
by Kiyotaka
44:57
created

EccubeRouter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 92.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 48
ccs 13
cts 14
cp 0.9286
rs 10
c 1
b 0
f 0
wmc 5
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setRequireHttps() 0 4 1
A setAdminPrefix() 0 4 1
A setUserDataPrefix() 0 4 1
B getRouteCollection() 0 24 2
1
<?php
2
3
namespace Eccube\Routing;
4
5
use Symfony\Component\Routing\Router;
6
7
class EccubeRouter extends Router
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
8
{
9
    protected $requireHttps = false;
10
11
    protected $adminPrefix = 'admin';
12
13
    protected $userDataPrefix = 'user_data';
14
15 1178
    public function setRequireHttps($requireHttps)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
16
    {
17 1178
        $this->requireHttps = (bool)$requireHttps;
0 ignored issues
show
Coding Style introduced by
As per coding-style, a cast statement should be followed by a single space.
Loading history...
18
    }
19
20 1178
    public function setAdminPrefix($adminPrefix)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
21
    {
22 1178
        $this->adminPrefix = $adminPrefix;
23
    }
24
25 1178
    public function setUserDataPrefix($userDataPrefix)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
26
    {
27 1178
        $this->userDataPrefix = $userDataPrefix;
28
    }
29
30 478
    public function getRouteCollection()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
31
    {
32 478
        $collection = parent::getRouteCollection();
33
34 478
        if ($this->requireHttps) {
35
            $collection->setSchemes('https');
36
        }
37
38 478
        $collection->addRequirements(
39
            [
40 478
                '_admin' => $this->adminPrefix,
41 478
                '_user_data' => $this->userDataPrefix,
42
            ]
43
        );
44
45 478
        $collection->addDefaults(
46
            [
47
                '_admin' => $this->adminPrefix,
48
                '_user_data' => $this->userDataPrefix,
49
            ]
50
        );
51
52
        return $collection;
53
    }
54
}
55