TaskController   A
last analyzed

Complexity

Total Complexity 23

Size/Duplication

Total Lines 314
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 314
rs 10
c 0
b 0
f 0
wmc 23
lcom 1
cbo 3

14 Methods

Rating   Name   Duplication   Size   Complexity  
A searchTasks() 0 6 1
A getTask() 0 6 1
A getTaskByReference() 0 6 1
A getAllTasks() 0 6 1
A getOverdueTasks() 0 4 1
A getOverdueTasksByProject() 0 6 1
A openTask() 0 6 1
A closeTask() 0 6 1
A removeTask() 0 6 1
A moveTaskPosition() 0 6 1
A moveTaskToProject() 0 6 1
A duplicateTaskToProject() 0 6 1
B createTask() 0 40 5
B updateTask() 0 38 6
1
<?php
2
3
/*
4
 * This file is part of Jitamin.
5
 *
6
 * Copyright (C) Jitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Jitamin\Http\Controllers\Api;
13
14
use Jitamin\Filter\TaskProjectFilter;
15
use Jitamin\Model\TaskModel;
16
use Jitamin\Policy\ProjectPolicy;
17
use Jitamin\Policy\TaskPolicy;
18
19
/**
20
 * Task API controller.
21
 */
22
class TaskController extends Controller
23
{
24
    /**
25
     * Get the tasks for applied filter.
26
     *
27
     * @param int    $project_id
28
     * @param string $query
29
     *
30
     * @return array
31
     */
32
    public function searchTasks($project_id, $query)
33
    {
34
        ProjectPolicy::getInstance($this->container)->check($this->getClassName(), 'searchTasks', $project_id);
35
36
        return $this->taskLexer->build($query)->withFilter(new TaskProjectFilter($project_id))->toArray();
0 ignored issues
show
Documentation introduced by
The property taskLexer does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
37
    }
38
39
    /**
40
     * Fetch a task by the id.
41
     *
42
     * @param int $task_id Task id
43
     *
44
     * @return array
45
     */
46
    public function getTask($task_id)
47
    {
48
        TaskPolicy::getInstance($this->container)->check($this->getClassName(), 'getTask', $task_id);
49
50
        return $this->formatTask($this->taskFinderModel->getById($task_id));
0 ignored issues
show
Documentation introduced by
The property taskFinderModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
51
    }
52
53
    /**
54
     * Fetch a task by the reference (external id).
55
     *
56
     * @param int    $project_id Project id
57
     * @param string $reference  Task reference
58
     *
59
     * @return array
60
     */
61
    public function getTaskByReference($project_id, $reference)
62
    {
63
        ProjectPolicy::getInstance($this->container)->check($this->getClassName(), 'getTaskByReference', $project_id);
64
65
        return $this->formatTask($this->taskFinderModel->getByReference($project_id, $reference));
0 ignored issues
show
Documentation introduced by
The property taskFinderModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
66
    }
67
68
    /**
69
     * Get all tasks for a given project and status.
70
     *
71
     * @param int $project_id Project id
72
     * @param int $status_id  Status id
73
     *
74
     * @return array
75
     */
76
    public function getAllTasks($project_id, $status_id = TaskModel::STATUS_OPEN)
77
    {
78
        ProjectPolicy::getInstance($this->container)->check($this->getClassName(), 'getAllTasks', $project_id);
79
80
        return $this->formatTasks($this->taskFinderModel->getAll($project_id, $status_id));
0 ignored issues
show
Documentation introduced by
The property taskFinderModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
81
    }
82
83
    /**
84
     * Get a list of overdue tasks for all projects.
85
     *
86
     * @return array
87
     */
88
    public function getOverdueTasks()
89
    {
90
        return $this->taskFinderModel->getOverdueTasks();
0 ignored issues
show
Documentation introduced by
The property taskFinderModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
91
    }
92
93
    /**
94
     * Get a list of overdue tasks by project.
95
     *
96
     * @param int $project_id
97
     *
98
     * @return array
99
     */
100
    public function getOverdueTasksByProject($project_id)
101
    {
102
        ProjectPolicy::getInstance($this->container)->check($this->getClassName(), 'getOverdueTasksByProject', $project_id);
103
104
        return $this->taskFinderModel->getOverdueTasksByProject($project_id);
0 ignored issues
show
Documentation introduced by
The property taskFinderModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
105
    }
106
107
    /**
108
     * Mark a task open.
109
     *
110
     * @param int $task_id Task id
111
     *
112
     * @return bool
113
     */
114
    public function openTask($task_id)
115
    {
116
        TaskPolicy::getInstance($this->container)->check($this->getClassName(), 'openTask', $task_id);
117
118
        return $this->taskStatusModel->open($task_id);
0 ignored issues
show
Documentation introduced by
The property taskStatusModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
119
    }
120
121
    /**
122
     * Mark a task closed.
123
     *
124
     * @param int $task_id Task id
125
     *
126
     * @return bool
127
     */
128
    public function closeTask($task_id)
129
    {
130
        TaskPolicy::getInstance($this->container)->check($this->getClassName(), 'closeTask', $task_id);
131
132
        return $this->taskStatusModel->close($task_id);
0 ignored issues
show
Documentation introduced by
The property taskStatusModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
133
    }
134
135
    /**
136
     * Remove a task.
137
     *
138
     * @param int $task_id Task id
139
     *
140
     * @return bool
141
     */
142
    public function removeTask($task_id)
143
    {
144
        TaskPolicy::getInstance($this->container)->check($this->getClassName(), 'removeTask', $task_id);
145
146
        return $this->taskModel->remove($task_id);
0 ignored issues
show
Documentation introduced by
The property taskModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
147
    }
148
149
    /**
150
     * Move a task to another column or to another position.
151
     *
152
     * @param int  $project_id  Project id
153
     * @param int  $task_id     Task id
154
     * @param int  $column_id   Column id
155
     * @param int  $position    Position (must be >= 1)
156
     * @param int  $swimlane_id Swimlane id
157
     * @param bool $fire_events Fire events
0 ignored issues
show
Bug introduced by
There is no parameter named $fire_events. 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...
158
     * @param bool $onlyOpen    Do not move closed tasks
0 ignored issues
show
Bug introduced by
There is no parameter named $onlyOpen. 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...
159
     *
160
     * @return bool
161
     */
162
    public function moveTaskPosition($project_id, $task_id, $column_id, $position, $swimlane_id = 0)
163
    {
164
        ProjectPolicy::getInstance($this->container)->check($this->getClassName(), 'moveTaskPosition', $project_id);
165
166
        return $this->taskPositionModel->movePosition($project_id, $task_id, $column_id, $position, $swimlane_id);
0 ignored issues
show
Documentation introduced by
The property taskPositionModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
167
    }
168
169
    /**
170
     * Move a task to another project.
171
     *
172
     * @param int $task_id
173
     * @param int $project_id
174
     * @param int $swimlane_id
175
     * @param int $column_id
176
     * @param int $category_id
177
     * @param int $owner_id
178
     *
179
     * @return bool
180
     */
181
    public function moveTaskToProject($task_id, $project_id, $swimlane_id = null, $column_id = null, $category_id = null, $owner_id = null)
182
    {
183
        ProjectPolicy::getInstance($this->container)->check($this->getClassName(), 'moveTaskToProject', $project_id);
184
185
        return $this->taskProjectMoveModel->moveToProject($task_id, $project_id, $swimlane_id, $column_id, $category_id, $owner_id);
0 ignored issues
show
Documentation introduced by
The property taskProjectMoveModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
186
    }
187
188
    /**
189
     * Duplicate a task to another project.
190
     *
191
     * @param int $task_id
192
     * @param int $project_id
193
     * @param int $swimlane_id
194
     * @param int $column_id
195
     * @param int $category_id
196
     * @param int $owner_id
197
     *
198
     * @return bool|int
199
     */
200
    public function duplicateTaskToProject($task_id, $project_id, $swimlane_id = null, $column_id = null, $category_id = null, $owner_id = null)
201
    {
202
        ProjectPolicy::getInstance($this->container)->check($this->getClassName(), 'duplicateTaskToProject', $project_id);
203
204
        return $this->taskProjectDuplicationModel->duplicateToProject($task_id, $project_id, $swimlane_id, $column_id, $category_id, $owner_id);
0 ignored issues
show
Documentation introduced by
The property taskProjectDuplicationModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
205
    }
206
207
    /**
208
     * Create a task.
209
     *
210
     * @param string $title
211
     * @param int    $project_id
212
     * @param string $color_id
213
     * @param int    $column_id
214
     * @param int    $owner_id
215
     * @param int    $creator_id
216
     * @param string $date_due
217
     * @param string $description
218
     * @param int    $category_id
219
     * @param int    $score
220
     * @param int    $swimlane_id
221
     * @param int    $priority
222
     * @param int    $recurrence_status
223
     * @param int    $recurrence_trigger
224
     * @param int    $recurrence_factor
225
     * @param int    $recurrence_timeframe
226
     * @param int    $recurrence_basedate
227
     * @param string $reference
228
     *
229
     * @return int
230
     */
231
    public function createTask($title, $project_id, $color_id = '', $column_id = 0, $owner_id = 0, $creator_id = 0,
232
                                $date_due = '', $description = '', $category_id = 0, $score = 0, $swimlane_id = 0, $priority = 0,
233
                                $recurrence_status = 0, $recurrence_trigger = 0, $recurrence_factor = 0, $recurrence_timeframe = 0,
234
                                $recurrence_basedate = 0, $reference = '')
235
    {
236
        ProjectPolicy::getInstance($this->container)->check($this->getClassName(), 'createTask', $project_id);
237
238
        if ($owner_id !== 0 && !$this->projectPermissionModel->isAssignable($project_id, $owner_id)) {
0 ignored issues
show
Documentation introduced by
The property projectPermissionModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
239
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by Jitamin\Http\Controllers...kController::createTask of type integer.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
240
        }
241
242
        if ($this->userSession->isLogged()) {
0 ignored issues
show
Documentation introduced by
The property userSession does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
243
            $creator_id = $this->userSession->getId();
0 ignored issues
show
Documentation introduced by
The property userSession does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
244
        }
245
246
        $values = [
247
            'title'                => $title,
248
            'project_id'           => $project_id,
249
            'color_id'             => $color_id,
250
            'column_id'            => $column_id,
251
            'owner_id'             => $owner_id,
252
            'creator_id'           => $creator_id,
253
            'date_due'             => $date_due,
254
            'description'          => $description,
255
            'category_id'          => $category_id,
256
            'score'                => $score,
257
            'swimlane_id'          => $swimlane_id,
258
            'recurrence_status'    => $recurrence_status,
259
            'recurrence_trigger'   => $recurrence_trigger,
260
            'recurrence_factor'    => $recurrence_factor,
261
            'recurrence_timeframe' => $recurrence_timeframe,
262
            'recurrence_basedate'  => $recurrence_basedate,
263
            'reference'            => $reference,
264
            'priority'             => $priority,
265
        ];
266
267
        list($valid) = $this->taskValidator->validateCreation($values);
0 ignored issues
show
Documentation introduced by
The property taskValidator does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
268
269
        return $valid ? $this->taskModel->create($values) : false;
0 ignored issues
show
Documentation introduced by
The property taskModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
270
    }
271
272
    /**
273
     * Update a task.
274
     *
275
     * @param int    $id
276
     * @param string $title
277
     * @param int    $project_id
0 ignored issues
show
Bug introduced by
There is no parameter named $project_id. 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...
278
     * @param string $color_id
279
     * @param int    $column_id
0 ignored issues
show
Bug introduced by
There is no parameter named $column_id. 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...
280
     * @param int    $owner_id
281
     * @param int    $creator_id
0 ignored issues
show
Bug introduced by
There is no parameter named $creator_id. 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...
282
     * @param string $date_due
283
     * @param string $description
284
     * @param int    $category_id
285
     * @param int    $score
286
     * @param int    $swimlane_id
0 ignored issues
show
Bug introduced by
There is no parameter named $swimlane_id. 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...
287
     * @param int    $priority
288
     * @param int    $recurrence_status
289
     * @param int    $recurrence_trigger
290
     * @param int    $recurrence_factor
291
     * @param int    $recurrence_timeframe
292
     * @param int    $recurrence_basedate
293
     * @param string $reference
294
     *
295
     * @return int
296
     */
297
    public function updateTask($id, $title = null, $color_id = null, $owner_id = null,
298
                                $date_due = null, $description = null, $category_id = null, $score = null, $priority = null,
299
                                $recurrence_status = null, $recurrence_trigger = null, $recurrence_factor = null,
300
                                $recurrence_timeframe = null, $recurrence_basedate = null, $reference = null)
301
    {
302
        TaskPolicy::getInstance($this->container)->check($this->getClassName(), 'updateTask', $id);
303
        $project_id = $this->taskFinderModel->getProjectId($id);
0 ignored issues
show
Documentation introduced by
The property taskFinderModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
304
305
        if ($project_id === 0) {
306
            return false;
307
        }
308
309
        if ($owner_id !== null && $owner_id != 0 && !$this->projectPermissionModel->isAssignable($project_id, $owner_id)) {
0 ignored issues
show
Documentation introduced by
The property projectPermissionModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
310
            return false;
311
        }
312
313
        $values = $this->filterValues([
314
            'id'                   => $id,
315
            'title'                => $title,
316
            'color_id'             => $color_id,
317
            'owner_id'             => $owner_id,
318
            'date_due'             => $date_due,
319
            'description'          => $description,
320
            'category_id'          => $category_id,
321
            'score'                => $score,
322
            'recurrence_status'    => $recurrence_status,
323
            'recurrence_trigger'   => $recurrence_trigger,
324
            'recurrence_factor'    => $recurrence_factor,
325
            'recurrence_timeframe' => $recurrence_timeframe,
326
            'recurrence_basedate'  => $recurrence_basedate,
327
            'reference'            => $reference,
328
            'priority'             => $priority,
329
        ]);
330
331
        list($valid) = $this->taskValidator->validateApiModification($values);
0 ignored issues
show
Documentation introduced by
The property taskValidator does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
332
333
        return $valid && $this->taskModel->update($values);
0 ignored issues
show
Documentation introduced by
The property taskModel does not exist on object<Jitamin\Http\Cont...ers\Api\TaskController>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
334
    }
335
}
336