Completed
Push — master ( 84b8e9...9ac9a8 )
by Valentin
03:43
created

KillCommand::getGroup()   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\Exception;
6
use Pheanstalk\Structure\TaskInstance;
7
use Pheanstalk\Structure\Workflow;
8
use Pheanstalk\Structure\WorkflowInstance;
9
use Pheanstalk\XmlResponseParser;
10
11
/**
12
 * The 'Kill' command.
13
 *
14
 * Kills a running workflow instance
15
 *
16
 *
17
 * @author  Valentin Corre
18
 * @package Pheanstalk
19
 * @license http://www.opensource.org/licenses/mit-license.php
20
 */
21
class KillCommand extends AbstractCommand implements \Pheanstalk\ResponseParser
22
{
23
24
    /** @var WorkflowInstance $workflowInstance */
25
    private $workflowInstance;
26
27
    /** @var TaskInstance $taskInstance */
28
    private $taskInstance;
29
30
    /**
31
     * Kills a running task instance
32
     *
33
     * @param WorkflowInstance $workflowInstance     The WorkflowInstance
34
     */
35 1
    public function __construct(WorkflowInstance $workflowInstance, TaskInstance $taskInstance)
36
    {
37 1
        $this->workflowInstance = $workflowInstance;
38 1
        $this->taskInstance = $taskInstance;
39
    }
40
41
    /**
42
     * @inheritDoc
43
     */
44 1
    public function getGroup(): string
45
    {
46 1
        return 'instance';
47
    }
48
49
    /**
50
     * @inheritDoc
51
     */
52 1
    public function getAction(): string
53
    {
54 1
        return 'killtask';
55
    }
56
57
    /**
58
     * @inheritDoc
59
     */
60 1
    public function getFilters(): array
61
    {
62
        return [
63 1
            'id' => $this->workflowInstance->getId(),
64 1
            'pid' => $this->taskInstance->getPid(),
65
        ];
66
    }
67
68
    /**
69
     * @inheritDoc
70
     */
71 1
    public function getResponseParser()
72
    {
73 1
        return $this;
74
    }
75
76
    /**
77
     * @inheritDoc
78
     */
79 1
    public function parseResponse($responseLine, $responseData)
80
    {
81 1
        return $responseLine === 'OK';
82
    }
83
}
84