UpdateCommand::parseResponse()   A
last analyzed

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 2
crap 1
1
<?php
2
3
namespace Pheanstalk\Command;
4
5
use Pheanstalk\ResponseParser;
6
use Pheanstalk\Structure\Workflow;
7
8
/**
9
 * The 'update' command.
10
 *
11
 * Update an existing job.
12
 *
13
 * @author  Valentin Corre
14
 * @package Pheanstalk
15
 * @license http://www.opensource.org/licenses/mit-license.php
16
 */
17
class UpdateCommand extends AbstractCommand implements ResponseParser
18
{
19
    /** @var Workflow $workflow */
20
    private $workflow;
21
22
    /**
23
     * @param Workflow $workflow
24
     */
25 1
    public function __construct(Workflow $workflow)
26
    {
27 1
        $this->workflow = $workflow;
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33 1
    public function getGroup(): string
34
    {
35 1
        return 'workflow';
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41 1
    public function getAction(): string
42
    {
43 1
        return 'edit';
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49 1
    public function getFilters(): array
50
    {
51
        return [
52 1
            'id' => $this->workflow->getId(),
53 1
            'name' => $this->workflow->getName(),
54 1
            "group" => $this->workflow->getGroup(),
55 1
            'content' => base64_encode($this->workflow->getXml()->saveXML()),
56 1
            'comment' => $this->workflow->getComment()
57
        ];
58
    }
59
60
    /**
61
     * @inheritDoc
62
     */
63 1
    public function getResponseParser()
64
    {
65 1
        return $this;
66
    }
67
68
    /**
69
     * @inheritDoc
70
     */
71 1
    public function parseResponse($responseLine, $responseData)
72
    {
73 1
        return $this->workflow;
74
    }
75
}
76