UpdateCommand   A
last analyzed

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\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