Passed
Pull Request — master (#28)
by Valentin
03:08
created

KillCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

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

5 Methods

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