Completed
Push — master ( 06d8dc...4a3b8a )
by Valentin
04:16
created

KillCommand   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 12
c 1
b 0
f 0
dl 0
loc 61
ccs 14
cts 14
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getResponseParser() 0 3 1
A parseResponse() 0 3 1
A getAction() 0 3 1
A getGroup() 0 3 1
A getFilters() 0 5 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