BaseScheduleEntityTrait::setTask()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php namespace Comodojo\Extender\Traits;
2
3
use \Comodojo\Extender\Task\TaskParameters;
4
5
/**
6
 * @package     Comodojo Extender
7
 * @author      Marco Giovinazzi <[email protected]>
8
 * @license     MIT
9
 *
10
 * LICENSE:
11
 *
12
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18
 * THE SOFTWARE.
19
 */
20
21
trait BaseScheduleEntityTrait {
22
23
    /**
24
     * @var integer
25
     *
26
     * @ORM\Column(name="id", type="integer", nullable=false)
27
     * @ORM\Id
28
     * @ORM\GeneratedValue(strategy="IDENTITY")
29
     */
30
    protected $id;
31
32
    /**
33
     * @var string
34
     *
35
     * @ORM\Column(name="name", type="string", length=256, nullable=false)
36
     */
37
    protected $name;
38
39
    /**
40
     * @var string
41
     *
42
     * @ORM\Column(name="task", type="string", length=256, nullable=false)
43
     */
44
    protected $task;
45
46
    /**
47
     * @var string
48
     *
49
     * @ORM\Column(name="parameters", type="array", nullable=false)
50
     */
51
    protected $parameters = [];
52
53
    /**
54
     * Get queue item's id
55
     *
56
     * @return integer
57
     */
58
    public function getId() {
59
60
        return $this->id;
61
62
    }
63
64
    /**
65
     * Set queue item's id
66
     *
67
     * @param string $id
68
     * @return Schedule
0 ignored issues
show
Bug introduced by
The type Comodojo\Extender\Traits\Schedule was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
69
     */
70
    public function setId($id) {
71
72
        $this->id = $id;
0 ignored issues
show
Documentation Bug introduced by
The property $id was declared of type integer, but $id is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
73
74
        return $this;
75
76
    }
77
78
    /**
79
     * Get queue item's name
80
     *
81
     * @return string
82
     */
83
    public function getName() {
84
85
        return $this->name;
86
87
    }
88
89
    /**
90
     * Set queue item's name
91
     *
92
     * @param string $name
93
     * @return Schedule
94
     */
95
    public function setName($name) {
96
97
        $this->name = $name;
98
99
        return $this;
100
101
    }
102
103
    /**
104
     * Get associated task
105
     *
106
     * @return string
107
     */
108
    public function getTask() {
109
110
        return $this->task;
111
112
    }
113
114
    /**
115
     * Set associated task
116
     *
117
     * @param string $task
118
     * @return Schedule
119
     */
120
    public function setTask($task) {
121
122
        $this->task = $task;
123
124
        return $this;
125
126
    }
127
128
    /**
129
     * Get queue item's parameters
130
     *
131
     * @return TaskParameters
132
     */
133
    public function getParameters() {
134
135
        return new TaskParameters($this->parameters);
0 ignored issues
show
Bug introduced by
$this->parameters of type string is incompatible with the type array expected by parameter $parameters of Comodojo\Extender\Task\T...rameters::__construct(). ( Ignorable by Annotation )

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

135
        return new TaskParameters(/** @scrutinizer ignore-type */ $this->parameters);
Loading history...
136
137
    }
138
139
    /**
140
     * Set queue item's parameters
141
     *
142
     * @param TaskParameters $parameters
143
     * @return Schedule
144
     */
145
    public function setParameters(TaskParameters $parameters) {
146
147
        $this->parameters = $parameters->get();
0 ignored issues
show
Documentation Bug introduced by
It seems like $parameters->get() of type array is incompatible with the declared type string of property $parameters.

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...
148
149
        return $this;
150
151
    }
152
153
    /**
154
     * Returns the properties of this object as an array for ease of use
155
     *
156
     * @return array
157
     */
158
    public function toArray() {
159
160
        return get_object_vars($this);
161
162
    }
163
164
}
165