Standard   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 55
rs 10
c 1
b 0
f 0
ccs 18
cts 20
cp 0.9
wmc 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A preMatch() 0 10 3
A postMatch() 0 7 2
A assemble() 0 7 3
A validateController() 0 8 2
1
<?php
2
3
namespace Nip\Router\Parsers;
4
5
/**
6
 * Class Standard
7
 * @package Nip\Router\Parsers
8
 */
9
class Standard extends Dynamic
10
{
11
    protected $map = ':controller/:action';
12
13
    /**
14
     * @param array $params
15
     * @return mixed|string
16
     */
17 1
    public function assemble($params = [])
18
    {
19 1
        if (!isset($params['action']) or !$params['action']) {
20 1
            $params['action'] = '';
21
        }
22
23 1
        return parent::assemble($params);
24
    }
25
26
    /** @noinspection PhpMissingParentCallCommonInspection
27
     * @return bool
28
     */
29 2
    protected function preMatch()
30
    {
31 2
        $mapCount = count($this->getParts());
32 2
        $uriCount = count($this->getUriParts());
33 2
        $difference = $mapCount - $uriCount;
34 2
        if ($difference == 0 || $difference == 1) {
35 2
            return true;
36
        }
37
38 2
        return false;
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44 2
    protected function postMatch()
45
    {
46 2
        if (parent::postMatch()) {
47 2
            return $this->validateController();
48
        }
49
50
        return false;
51
    }
52
53
    /**
54
     * @return bool
55
     */
56 2
    protected function validateController()
57
    {
58 2
        $controller = $this->getParam('controller');
59 2
        if (!empty($controller)) {
60 2
            return true;
61
        }
62
63
        return false;
64
    }
65
}
66