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

CreateTubeCommand::getFilters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
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\Response;
7
use Pheanstalk\Structure\Tube;
8
use Pheanstalk\Structure\Workflow;
9
use Pheanstalk\XmlResponseParser;
10
11
/**
12
 * The 'CreateTube' command.
13
 *
14
 * Inserts a new Tube into the EvQueue.
15
 *
16
 *
17
 * @author  Valentin Corre
18
 * @package Pheanstalk
19
 * @license http://www.opensource.org/licenses/mit-license.php
20
 */
21
class CreateTubeCommand extends AbstractCommand implements \Pheanstalk\ResponseParser
22
{
23
24
    /** @var Tube $tube */
25
    private $tube;
26
27
    /**
28
     * Puts a job on the queue.
29
     *
30
     * @param Workflow    $workflow     The workflow to create
31
     */
32 1
    public function __construct(Tube $tube)
33
    {
34 1
        $this->tube = $tube;
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40 1
    public function getGroup(): string
41
    {
42 1
        return 'queue';
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48 1
    public function getAction(): string
49
    {
50 1
        return 'create';
51
    }
52
53
    /**
54
     * @inheritDoc
55
     */
56 1
    public function getFilters(): array
57
    {
58
        return [
59 1
            'name' => $this->tube->getName(),
60 1
            "concurrency" => $this->tube->getConcurrency(),
61 1
            'scheduler' => $this->tube->getScheduler(),
62 1
            'dynamic' => $this->tube->getDynamic(),
63
        ];
64
    }
65
66
    /**
67
     * @inheritDoc
68
     */
69 1
    public function getResponseParser()
70
    {
71 1
        return $this;
72
    }
73
74
    /**
75
     * @inheritDoc
76
     */
77 1
    public function parseResponse($responseLine, $responseData)
78
    {
79 1
        $this->tube->setId($responseData['@attributes']['queue-id']);
80 1
        return $this->tube;
81
    }
82
}
83