Completed
Branch master (450f26)
by Valentin
01:46
created

PutCommand::__construct()   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 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 1
crap 1
1
<?php
2
3
namespace Pheanstalk\Command;
4
5
use Pheanstalk\Exception;
6
use Pheanstalk\Structure\Workflow;
7
use Pheanstalk\XmlResponseParser;
8
9
/**
10
 * The 'put' command.
11
 *
12
 * Inserts a job into the client's currently used tube.
13
 *
14
 * @see UseCommand
15
 *
16
 * @author  Paul Annesley
17
 * @package Pheanstalk
18
 * @license http://www.opensource.org/licenses/mit-license.php
19
 */
20
class PutCommand extends AbstractCommand implements \Pheanstalk\ResponseParser
21
{
22
23
    /** @var Workflow $workflow */
24
    private $workflow;
25
26
    /**
27
     * Puts a workflow in queue.
28
     *
29
     * @param Workflow $workflow     The Workflow
30
     */
31 2
    public function __construct(Workflow $workflow)
32
    {
33 2
        $this->workflow = $workflow;
34
    }
35
36
    /**
37
     * @inheritDoc
38
     */
39 2
    public function getGroup(): string
40
    {
41 2
        return 'instance';
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47 2
    public function getAction(): string
48
    {
49 2
        return 'launch';
50
    }
51
52
    /**
53
     * @inheritDoc
54
     */
55 2
    public function getFilters(): array
56
    {
57
        return [
58 2
            'name' => $this->workflow->getName(),
59
        ];
60
    }
61
62
    /**
63
     * @inheritDoc
64
     */
65 2
    public function getResponseParser()
66
    {
67 2
        return $this;
68
    }
69
70
    /**
71
     * @inheritDoc
72
     */
73 2
    public function parseResponse($responseLine, $responseData)
74
    {
75 2
        return $responseData['@attributes'];
76
    }
77
}
78