Passed
Push — master ( 4a6f0d...73b924 )
by Valentin
03:29
created

UpdateTubeCommand::getResponseParser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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 'UpdateTube' command.
13
 *
14
 * Updates an existing tube
15
 *
16
 *
17
 * @author  Valentin Corre
18
 * @package Pheanstalk
19
 * @license http://www.opensource.org/licenses/mit-license.php
20
 */
21
class UpdateTubeCommand extends AbstractCommand implements \Pheanstalk\ResponseParser
22
{
23
24
    /** @var Tube $tube */
25
    private $tube;
26
27
    /**
28
     * Updates an existing tube
29
     *
30
     * @param Workflow    $workflow     The workflow to create
31
     */
32
    public function __construct(Tube $tube)
33
    {
34
        $this->tube = $tube;
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    public function getGroup(): string
41
    {
42
        return 'queue';
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48
    public function getAction(): string
49
    {
50
        return 'edit';
51
    }
52
53
    /**
54
     * @inheritDoc
55
     */
56
    public function getFilters(): array
57
    {
58
        return [
59
            'id' => $this->tube->getId(),
60
            'name' => $this->tube->getName(),
61
            "concurrency" => $this->tube->getConcurrency(),
62
            'scheduler' => $this->tube->getScheduler(),
63
            'dynamic' => $this->tube->getDynamic(),
64
        ];
65
    }
66
67
    /**
68
     * @inheritDoc
69
     */
70
    public function getResponseParser()
71
    {
72
        return $this;
73
    }
74
75
    /**
76
     * @inheritDoc
77
     */
78
    public function parseResponse($responseLine, $responseData)
79
    {
80
        return $this->tube;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->tube returns the type Pheanstalk\Structure\Tube which is incompatible with the return type mandated by Pheanstalk\ResponseParser::parseResponse() of Pheanstalk\Response.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
81
    }
82
}
83