AbstractStage   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 53
ccs 13
cts 13
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getCommand() 0 3 1
A __invoke() 0 5 1
A hasInstanceAction() 0 3 1
A hasClassAction() 0 3 1
A setCommand() 0 3 1
1
<?php
2
3
namespace Nip\Dispatcher\Resolver\Pipeline\Stages;
4
5
use Nip\Dispatcher\Commands\Command;
6
7
/**
8
 * Class AbstractStage
9
 * @package Nip\Dispatcher\Resolver\Pipeline\Stages
10
 */
11
abstract class AbstractStage implements StageInterface
12
{
13
    /**
14
     * @var Command
15
     */
16
    protected $command;
17
18
    /**
19
     * @param Command $methodCall
20
     * @return Command
21
     */
22 5
    public function __invoke(Command $command): Command
23
    {
24 5
        $this->setCommand($command);
25 5
        $this->processCommand();
26 5
        return $command;
27
    }
28
29
    /**
30
     * @return void
31
     */
32
    abstract public function processCommand();
33
34
    /**
35
     * @return Command
36
     */
37 5
    public function getCommand(): Command
38
    {
39 5
        return $this->command;
40
    }
41
42
    /**
43
     * @param Command $command
44
     */
45 5
    public function setCommand(Command $command)
46
    {
47 5
        $this->command = $command;
48 5
    }
49
50
    /**
51
     * @return bool
52
     */
53 3
    protected function hasClassAction()
54
    {
55 3
        return $this->getCommand()->hasActionParam('class');
56
    }
57
58
    /**
59
     * @return bool
60
     */
61 4
    protected function hasInstanceAction()
62
    {
63 4
        return $this->getCommand()->hasActionParam('instance');
64
    }
65
}
66