Completed
Pull Request — master (#5)
by Jacob
03:21
created

PortfolioRouter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 56
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B get_redirect_array() 0 25 1
B get_direct_array() 0 25 1
1
<?
0 ignored issues
show
Security Best Practice introduced by
It is not recommend to use PHP's short opening tag <?, better use <?php, or <?= in case of outputting.

Short opening tags are disabled in PHP’s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.

As a precaution to avoid these problems better use the long opening tag <?php.

Loading history...
2
3
Loader::load('router', 'Router');
4
5
class PortfolioRouter extends Router
6
{
7
8
    protected function get_redirect_array()
9
    {
10
        $paths = [
11
            [
12
                'pattern' => '@/index.(html|htm|php)$@',
13
                'replace' => '/',
14
            ],
15
            [
16
                'pattern' => '@^/print(/?)$@',
17
                'replace' => '/projects/',
18
            ],
19
            [
20
                'pattern' => '@^/web(/?)$@',
21
                'replace' => '/projects/',
22
            ],
23
            [
24
                'pattern' => '@^/(web|print)/([a-z0-9-]+)(/?)$@',
25
                'replace' => '/projects/',
26
            ],
27
        ];
28
29
        return array_map(function ($row) {
30
            return (object) $row;
31
        }, $paths);
32
    }
33
34
    protected function get_direct_array()
35
    {
36
        $paths = [
37
            [
38
                'match' => '/',
39
                'controller' => 'AboutController',
40
            ],
41
            [
42
                'match' => '/contact/',
43
                'controller' => 'ContactController',
44
            ],
45
            [
46
                'match' => '/projects/',
47
                'controller' => 'ProjectsController',
48
            ],
49
            [
50
                'match' => '/resume/',
51
                'controller' => 'ResumeController',
52
            ],
53
        ];
54
55
        return array_map(function ($row) {
56
            return (object) $row;
57
        }, $paths);
58
    }
59
60
}
61