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