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

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