Passed
Pull Request — master (#28)
by Valentin
04:18
created

KillCommand::getAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Pheanstalk\Command;
4
5
use Pheanstalk\Parser\RequestOkResponseParser;
6
use Pheanstalk\Structure\TaskInstance;
7
use Pheanstalk\Structure\WorkflowInstance;
8
9
/**
10
 * The 'Kill' command.
11
 *
12
 * Kills a running workflow instance
13
 *
14
 *
15
 * @author  Valentin Corre
16
 * @package Pheanstalk
17
 * @license http://www.opensource.org/licenses/mit-license.php
18
 */
19
class KillCommand extends AbstractCommand
20
{
21
22
    /** @var WorkflowInstance $workflowInstance */
23
    private $workflowInstance;
24
25
    /** @var TaskInstance $taskInstance */
26
    private $taskInstance;
27
28
    /**
29
     * Kills a running task instance
30
     *
31
     * @param WorkflowInstance $workflowInstance     The WorkflowInstance
32
     */
33 1
    public function __construct(WorkflowInstance $workflowInstance, TaskInstance $taskInstance)
34
    {
35 1
        $this->workflowInstance = $workflowInstance;
36 1
        $this->taskInstance = $taskInstance;
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42 1
    public function getGroup(): string
43
    {
44 1
        return 'instance';
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50 1
    public function getAction(): string
51
    {
52 1
        return 'killtask';
53
    }
54
55
    /**
56
     * @inheritDoc
57
     */
58 1
    public function getFilters(): array
59
    {
60
        return [
61 1
            'id' => $this->workflowInstance->getId(),
62 1
            'pid' => $this->taskInstance->getPid(),
63
        ];
64
    }
65
66
    /**
67
     * @inheritDoc
68
     */
69
    public function getResponseParser()
70
    {
71
        return new RequestOkResponseParser();
72
    }
73
}
74