Passed
Pull Request — master (#28)
by Valentin
04:39
created

UpdateScheduleCommand   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 17
c 1
b 0
f 0
dl 0
loc 61
ccs 0
cts 33
cp 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getAction() 0 3 1
A parseResponse() 0 4 1
A getResponseParser() 0 3 1
A getGroup() 0 3 1
A getFilters() 0 11 1
A __construct() 0 3 1
1
<?php
2
3
namespace Pheanstalk\Command;
4
5
use Pheanstalk\ResponseParser;
6
use Pheanstalk\Structure\Schedule;
7
use Pheanstalk\Structure\Workflow;
8
9
/**
10
 * The 'update' command.
11
 *
12
 * Update an existing Schedule.
13
 *
14
 * @author  Valentin Corre
15
 * @package Pheanstalk
16
 * @license http://www.opensource.org/licenses/mit-license.php
17
 */
18
class UpdateScheduleCommand extends AbstractCommand implements ResponseParser
19
{
20
    /** @var Workflow $workflow */
21
    private $schedule;
22
23
    /**
24
     * @param Schedule $schedule
25
     */
26
    public function __construct(Schedule $schedule)
27
    {
28
        $this->schedule = $schedule;
0 ignored issues
show
Documentation Bug introduced by
It seems like $schedule of type Pheanstalk\Structure\Schedule is incompatible with the declared type Pheanstalk\Structure\Workflow of property $schedule.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34
    public function getGroup(): string
35
    {
36
        return 'workflow_schedule';
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42
    public function getAction(): string
43
    {
44
        return 'edit';
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50
    public function getFilters(): array
51
    {
52
        return [
53
            'id' => $this->schedule->getId(),
54
            'workflow_id' => $this->schedule->getWorkflow(),
0 ignored issues
show
Bug introduced by
The method getWorkflow() does not exist on Pheanstalk\Structure\Workflow. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
            'workflow_id' => $this->schedule->/** @scrutinizer ignore-call */ getWorkflow(),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
            'schedule' => $this->schedule->getSchedule()->__toString(),
0 ignored issues
show
Bug introduced by
The method getSchedule() does not exist on Pheanstalk\Structure\Workflow. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
            'schedule' => $this->schedule->/** @scrutinizer ignore-call */ getSchedule()->__toString(),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
            'onfailure' => $this->schedule->getOnFailure(),
0 ignored issues
show
Bug introduced by
The method getOnFailure() does not exist on Pheanstalk\Structure\Workflow. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
            'onfailure' => $this->schedule->/** @scrutinizer ignore-call */ getOnFailure(),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
            'user' => $this->schedule->getUser(),
0 ignored issues
show
Bug introduced by
The method getUser() does not exist on Pheanstalk\Structure\Workflow. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
            'user' => $this->schedule->/** @scrutinizer ignore-call */ getUser(),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
58
            'host' => $this->schedule->getHost(),
0 ignored issues
show
Bug introduced by
The method getHost() does not exist on Pheanstalk\Structure\Workflow. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

58
            'host' => $this->schedule->/** @scrutinizer ignore-call */ getHost(),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
59
            'active' => $this->schedule->isActive(),
0 ignored issues
show
Bug introduced by
The method isActive() does not exist on Pheanstalk\Structure\Workflow. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

59
            'active' => $this->schedule->/** @scrutinizer ignore-call */ isActive(),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
            "comment" => $this->schedule->getComment()
61
        ];
62
    }
63
64
    /**
65
     * @inheritDoc
66
     */
67
    public function getResponseParser()
68
    {
69
        return $this;
70
    }
71
72
    /**
73
     * @inheritDoc
74
     */
75
    public function parseResponse($responseLine, $responseData)
76
    {
77
        var_dump($responseData);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($responseData) looks like debug code. Are you sure you do not want to remove it?
Loading history...
78
        return $this->schedule;
79
    }
80
}
81