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

UpdateCommand   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 13
c 1
b 0
f 0
dl 0
loc 57
ccs 16
cts 16
cp 1
rs 10

6 Methods

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