Completed
Push — 2.0 ( 76e968...4129d9 )
by Marco
13:01
created

Request   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 10
lcom 0
cbo 0
dl 0
loc 121
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getName() 0 5 1
A setName() 0 7 1
A getTaskRequest() 0 5 1
A setTaskRequest() 0 7 1
A getDescription() 0 5 1
A setDescription() 0 7 1
A getExpression() 0 5 1
A setCronExpression() 0 7 1
A create() 0 5 1
1
<?php namespace Comodojo\Extender\Schedule;
2
3
use \Comodojo\Extender\Task\Request as TaskRequest;
4
use \Cron\CronExpression;
5
6
/**
7
* @package     Comodojo Extender
8
* @author      Marco Giovinazzi <[email protected]>
9
* @license     MIT
10
*
11
* LICENSE:
12
*
13
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
* THE SOFTWARE.
20
 */
21
22
class Request {
23
24
    /**
25
     * @var string
26
     */
27
    protected $name;
28
29
    /**
30
     * @var string
31
     */
32
    protected $description;
33
34
    /**
35
     * @var TaskRequest
36
     */
37
    protected $request;
38
39
    /**
40
     * @var string
41
     */
42
    protected $expression;
43
44
    /**
45
     * Class constructor
46
     *
47
     * @param string $name
48
     * @param string $task
0 ignored issues
show
Bug introduced by
There is no parameter named $task. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
49
     * @param TaskParameters $parameters
0 ignored issues
show
Bug introduced by
There is no parameter named $parameters. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
50
     */
51
    public function __construct($name, $expression, TaskRequest $request, $description = null) {
52
53
        $this->setName($name)
0 ignored issues
show
Bug introduced by
The method setExpression() does not seem to exist on object<Comodojo\Extender\Schedule\Request>.

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...
54
            ->setExpression($expression)
55
            ->setRequest($request)
56
            ->setDescription($description);
57
58
    }
59
60
    /**
61
     * Get request name
62
     *
63
     * @return string
64
     */
65
    public function getName() {
66
67
        return $this->name;
68
69
    }
70
71
    public function setName($name) {
72
73
        $this->name = $name;
74
75
        return $this;
76
77
    }
78
79
    /**
80
     * Get request associated task
81
     *
82
     * @return string
83
     */
84
    public function getTaskRequest() {
85
86
        return $this->request;
87
88
    }
89
90
    public function setTaskRequest(TaskRequest $request) {
91
92
        $this->request = $request;
93
94
        return $this;
95
96
    }
97
98
    /**
99
     * Get description
100
     *
101
     * @return string
102
     */
103
    public function getDescription() {
104
105
        return $this->description;
106
107
    }
108
109
    public function setDescription($description = null) {
110
111
        $this->description = $description;
112
113
        return $this;
114
115
    }
116
117
    /**
118
     * Get parent unique id
119
     *
120
     * @return int
121
     */
122
    public function getExpression() {
123
124
        return $this->expression;
125
126
    }
127
128
    public function setCronExpression(CronExpression $expression) {
129
130
        $this->expression = $expression;
0 ignored issues
show
Documentation Bug introduced by
It seems like $expression of type object<Cron\CronExpression> is incompatible with the declared type string of property $expression.

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...
131
132
        return $this;
133
134
    }
135
136
    public static function create($name, $task, TaskParameters $parameters = null) {
137
138
        return new Request($name, $task, $parameters);
0 ignored issues
show
Bug introduced by
It seems like $parameters defined by parameter $parameters on line 136 can also be of type null; however, Comodojo\Extender\Schedule\Request::__construct() does only seem to accept object<Comodojo\Extender\Task\Request>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
139
140
    }
141
142
}
143