RequestStage::processCommand()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 2
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 3
rs 10
1
<?php
2
3
namespace Nip\Dispatcher\Resolver\Pipeline\Stages;
4
5
/**
6
 * Class ClosureStage
7
 * @package Nip\Dispatcher\Resolver\Pipeline\Stages
8
 */
9
class RequestStage extends AbstractStage
10
{
11
    /**
12
     * @return void
13
     */
14 4
    public function processCommand()
15
    {
16 4
        if (!$this->getCommand()->hasAction() && $this->hasRequestMCA()) {
17 3
            $this->saveRequestParamsInCommand();
18
        }
19 4
    }
20
21 3
    protected function saveRequestParamsInCommand()
22
    {
23 3
        $request = $this->getRequest();
24
25 3
        $this->getCommand()->setActionParam('module', $request->getModuleName());
26 3
        $this->getCommand()->setActionParam('controller', $request->getControllerName());
27 3
        $this->getCommand()->setActionParam('action', $request->getActionName());
28 3
    }
29
30
    /**
31
     * @return bool
32
     */
33 4
    protected function hasRequestMCA()
34
    {
35 4
        return $this->getCommand()->hasRequest() && $this->getRequest()->getControllerName() !== null;
36
    }
37
38
    /**
39
     * @return \Nip\Request
40
     */
41 3
    protected function getRequest()
42
    {
43 3
        return $this->getCommand()->getRequest();
44
    }
45
}
46