Issues (3948)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

app/Models/TaskFinderModel.php (20 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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\Model;
13
14
use Jitamin\Foundation\Database\Model;
15
16
/**
17
 * Task Finder model.
18
 */
19
class TaskFinderModel extends Model
20
{
21
    /**
22
     * Get query for project user overview.
23
     *
24
     * @param array $project_ids
25
     * @param int   $is_active
26
     *
27
     * @return \PicoDb\Table
28
     */
29
    public function getProjectUserOverviewQuery(array $project_ids, $is_active)
30
    {
31
        if (empty($project_ids)) {
32
            $project_ids = [-1];
33
        }
34
35
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
36
                    ->table(TaskModel::TABLE)
37
                    ->columns(
38
                        TaskModel::TABLE.'.id',
39
                        TaskModel::TABLE.'.title',
40
                        TaskModel::TABLE.'.date_due',
41
                        TaskModel::TABLE.'.date_started',
42
                        TaskModel::TABLE.'.project_id',
43
                        TaskModel::TABLE.'.color_id',
44
                        TaskModel::TABLE.'.priority',
45
                        TaskModel::TABLE.'.time_spent',
46
                        TaskModel::TABLE.'.time_estimated',
47
                        TaskModel::TABLE.'.progress',
48
                        ProjectModel::TABLE.'.name AS project_name',
49
                        ColumnModel::TABLE.'.title AS column_name',
50
                        UserModel::TABLE.'.username AS assignee_username',
51
                        UserModel::TABLE.'.name AS assignee_name'
52
                    )
53
                    ->eq(TaskModel::TABLE.'.is_active', $is_active)
54
                    ->in(ProjectModel::TABLE.'.id', $project_ids)
55
                    ->join(ProjectModel::TABLE, 'id', 'project_id')
56
                    ->join(ColumnModel::TABLE, 'id', 'column_id', TaskModel::TABLE)
57
                    ->join(UserModel::TABLE, 'id', 'owner_id', TaskModel::TABLE);
58
    }
59
60
    /**
61
     * Get query for assigned user tasks.
62
     *
63
     * @param int $user_id User id
64
     *
65
     * @return \PicoDb\Table
66
     */
67
    public function getUserQuery($user_id)
68
    {
69
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
70
                    ->table(TaskModel::TABLE)
71
                    ->columns(
72
                        TaskModel::TABLE.'.id',
73
                        TaskModel::TABLE.'.title',
74
                        TaskModel::TABLE.'.date_due',
75
                        TaskModel::TABLE.'.date_creation',
76
                        TaskModel::TABLE.'.project_id',
77
                        TaskModel::TABLE.'.column_id',
78
                        TaskModel::TABLE.'.color_id',
79
                        TaskModel::TABLE.'.priority',
80
                        TaskModel::TABLE.'.time_spent',
81
                        TaskModel::TABLE.'.time_estimated',
82
                        TaskModel::TABLE.'.is_active',
83
                        TaskModel::TABLE.'.creator_id',
84
                        TaskModel::TABLE.'.progress',
85
                        ProjectModel::TABLE.'.name AS project_name',
86
                        ColumnModel::TABLE.'.title AS column_title'
87
                    )
88
                    ->join(ProjectModel::TABLE, 'id', 'project_id')
89
                    ->join(ColumnModel::TABLE, 'id', 'column_id')
90
                    ->eq(TaskModel::TABLE.'.owner_id', $user_id)
91
                    ->eq(TaskModel::TABLE.'.is_active', TaskModel::STATUS_OPEN)
92
                    ->eq(ProjectModel::TABLE.'.is_active', ProjectModel::ACTIVE)
93
                    ->eq(ColumnModel::TABLE.'.hide_in_dashboard', 0);
94
    }
95
96
    /**
97
     * Extended query.
98
     *
99
     * @return \PicoDb\Table
100
     */
101
    public function getExtendedQuery()
102
    {
103
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
104
            ->table(TaskModel::TABLE)
105
            ->columns(
106
                '(SELECT COUNT(*) FROM '.CommentModel::TABLE.' WHERE task_id=tasks.id) AS nb_comments',
107
                '(SELECT COUNT(*) FROM '.TaskFileModel::TABLE.' WHERE task_id=tasks.id) AS nb_files',
108
                '(SELECT COUNT(*) FROM '.SubtaskModel::TABLE.' WHERE '.SubtaskModel::TABLE.'.task_id=tasks.id) AS nb_subtasks',
109
                '(SELECT COUNT(*) FROM '.SubtaskModel::TABLE.' WHERE '.SubtaskModel::TABLE.'.task_id=tasks.id AND status=2) AS nb_completed_subtasks',
110
                '(SELECT COUNT(*) FROM '.TaskLinkModel::TABLE.' WHERE '.TaskLinkModel::TABLE.'.task_id = tasks.id) AS nb_links',
111
                '(SELECT COUNT(*) FROM '.TaskExternalLinkModel::TABLE.' WHERE '.TaskExternalLinkModel::TABLE.'.task_id = tasks.id) AS nb_external_links',
112
                '(SELECT DISTINCT 1 FROM '.TaskLinkModel::TABLE.' WHERE '.TaskLinkModel::TABLE.'.task_id = tasks.id AND '.TaskLinkModel::TABLE.'.link_id = 9) AS is_milestone',
113
                TaskModel::TABLE.'.id',
114
                TaskModel::TABLE.'.reference',
115
                TaskModel::TABLE.'.title',
116
                TaskModel::TABLE.'.description',
117
                TaskModel::TABLE.'.date_creation',
118
                TaskModel::TABLE.'.date_modification',
119
                TaskModel::TABLE.'.date_completed',
120
                TaskModel::TABLE.'.date_started',
121
                TaskModel::TABLE.'.date_due',
122
                TaskModel::TABLE.'.color_id',
123
                TaskModel::TABLE.'.project_id',
124
                TaskModel::TABLE.'.column_id',
125
                TaskModel::TABLE.'.swimlane_id',
126
                TaskModel::TABLE.'.owner_id',
127
                TaskModel::TABLE.'.creator_id',
128
                TaskModel::TABLE.'.position',
129
                TaskModel::TABLE.'.is_active',
130
                TaskModel::TABLE.'.score',
131
                TaskModel::TABLE.'.category_id',
132
                TaskModel::TABLE.'.priority',
133
                TaskModel::TABLE.'.date_moved',
134
                TaskModel::TABLE.'.recurrence_status',
135
                TaskModel::TABLE.'.recurrence_trigger',
136
                TaskModel::TABLE.'.recurrence_factor',
137
                TaskModel::TABLE.'.recurrence_timeframe',
138
                TaskModel::TABLE.'.recurrence_basedate',
139
                TaskModel::TABLE.'.recurrence_parent',
140
                TaskModel::TABLE.'.recurrence_child',
141
                TaskModel::TABLE.'.time_estimated',
142
                TaskModel::TABLE.'.time_spent',
143
                TaskModel::TABLE.'.progress',
144
                UserModel::TABLE.'.username AS assignee_username',
145
                UserModel::TABLE.'.name AS assignee_name',
146
                UserModel::TABLE.'.email AS assignee_email',
147
                UserModel::TABLE.'.avatar_path AS assignee_avatar_path',
148
                CategoryModel::TABLE.'.name AS category_name',
149
                CategoryModel::TABLE.'.description AS category_description',
150
                ColumnModel::TABLE.'.title AS column_name',
151
                ColumnModel::TABLE.'.position AS column_position',
152
                SwimlaneModel::TABLE.'.name AS swimlane_name',
153
                ProjectModel::TABLE.'.default_swimlane',
154
                ProjectModel::TABLE.'.name AS project_name'
155
            )
156
            ->join(UserModel::TABLE, 'id', 'owner_id', TaskModel::TABLE)
157
            ->left(UserModel::TABLE, 'uc', 'id', TaskModel::TABLE, 'creator_id')
158
            ->join(CategoryModel::TABLE, 'id', 'category_id', TaskModel::TABLE)
159
            ->join(ColumnModel::TABLE, 'id', 'column_id', TaskModel::TABLE)
160
            ->join(SwimlaneModel::TABLE, 'id', 'swimlane_id', TaskModel::TABLE)
161
            ->join(ProjectModel::TABLE, 'id', 'project_id', TaskModel::TABLE);
162
    }
163
164
    /**
165
     * Get all tasks for a given project and status.
166
     *
167
     * @param int $project_id Project id
168
     * @param int $status_id  Status id
169
     *
170
     * @return array
171
     */
172
    public function getAll($project_id, $status_id = TaskModel::STATUS_OPEN)
173
    {
174
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
175
                    ->table(TaskModel::TABLE)
176
                    ->eq(TaskModel::TABLE.'.project_id', $project_id)
177
                    ->eq(TaskModel::TABLE.'.is_active', $status_id)
178
                    ->asc(TaskModel::TABLE.'.id')
179
                    ->findAll();
180
    }
181
182
    /**
183
     * Get all tasks for a given project and status.
184
     *
185
     * @param int   $project_id
186
     * @param array $status
187
     *
188
     * @return array
189
     */
190 View Code Duplication
    public function getAllIds($project_id, array $status = [TaskModel::STATUS_OPEN])
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
191
    {
192
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
193
                    ->table(TaskModel::TABLE)
194
                    ->eq(TaskModel::TABLE.'.project_id', $project_id)
195
                    ->in(TaskModel::TABLE.'.is_active', $status)
196
                    ->asc(TaskModel::TABLE.'.id')
197
                    ->findAllByColumn(TaskModel::TABLE.'.id');
198
    }
199
200
    /**
201
     * Get overdue tasks query.
202
     *
203
     * @return \PicoDb\Table
204
     */
205
    public function getOverdueTasksQuery()
206
    {
207
        return $this->db->table(TaskModel::TABLE)
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
208
                    ->columns(
209
                        TaskModel::TABLE.'.id',
210
                        TaskModel::TABLE.'.title',
211
                        TaskModel::TABLE.'.date_due',
212
                        TaskModel::TABLE.'.project_id',
213
                        TaskModel::TABLE.'.creator_id',
214
                        TaskModel::TABLE.'.owner_id',
215
                        ProjectModel::TABLE.'.name AS project_name',
216
                        UserModel::TABLE.'.username AS assignee_username',
217
                        UserModel::TABLE.'.name AS assignee_name'
218
                    )
219
                    ->join(ProjectModel::TABLE, 'id', 'project_id')
220
                    ->join(UserModel::TABLE, 'id', 'owner_id')
221
                    ->eq(ProjectModel::TABLE.'.is_active', 1)
222
                    ->eq(TaskModel::TABLE.'.is_active', 1)
223
                    ->neq(TaskModel::TABLE.'.date_due', 0)
224
                    ->lte(TaskModel::TABLE.'.date_due', mktime(23, 59, 59));
225
    }
226
227
    /**
228
     * Get a list of overdue tasks for all projects.
229
     *
230
     * @return array
231
     */
232
    public function getOverdueTasks()
233
    {
234
        return $this->getOverdueTasksQuery()->findAll();
235
    }
236
237
    /**
238
     * Get a list of overdue tasks by project.
239
     *
240
     * @param int $project_id
241
     *
242
     * @return array
243
     */
244
    public function getOverdueTasksByProject($project_id)
245
    {
246
        return $this->getOverdueTasksQuery()->eq(TaskModel::TABLE.'.project_id', $project_id)->findAll();
247
    }
248
249
    /**
250
     * Get a list of overdue tasks by user.
251
     *
252
     * @param int $user_id
253
     *
254
     * @return array
255
     */
256
    public function getOverdueTasksByUser($user_id)
257
    {
258
        return $this->getOverdueTasksQuery()->eq(TaskModel::TABLE.'.owner_id', $user_id)->findAll();
259
    }
260
261
    /**
262
     * Get project id for a given task.
263
     *
264
     * @param int $task_id Task id
265
     *
266
     * @return int
267
     */
268
    public function getProjectId($task_id)
269
    {
270
        return (int) $this->db->table(TaskModel::TABLE)->eq('id', $task_id)->findOneColumn('project_id') ?: 0;
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
271
    }
272
273
    /**
274
     * Fetch a task by the id.
275
     *
276
     * @param int $task_id Task id
277
     *
278
     * @return array
279
     */
280
    public function getById($task_id)
281
    {
282
        return $this->db->table(TaskModel::TABLE)->eq('id', $task_id)->findOne();
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
283
    }
284
285
    /**
286
     * Fetch a task by the reference (external id).
287
     *
288
     * @param int    $project_id Project id
289
     * @param string $reference  Task reference
290
     *
291
     * @return array
292
     */
293
    public function getByReference($project_id, $reference)
294
    {
295
        return $this->db->table(TaskModel::TABLE)->eq('project_id', $project_id)->eq('reference', $reference)->findOne();
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
296
    }
297
298
    /**
299
     * Get task details (fetch more information from other tables).
300
     *
301
     * @param int $task_id Task id
302
     *
303
     * @return array
304
     */
305
    public function getDetails($task_id)
306
    {
307
        return $this->db->table(TaskModel::TABLE)
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
308
            ->columns(
309
                TaskModel::TABLE.'.*',
310
                CategoryModel::TABLE.'.name AS category_name',
311
                SwimlaneModel::TABLE.'.name AS swimlane_name',
312
                ProjectModel::TABLE.'.name AS project_name',
313
                ProjectModel::TABLE.'.default_swimlane',
314
                ColumnModel::TABLE.'.title AS column_title',
315
                UserModel::TABLE.'.username AS assignee_username',
316
                UserModel::TABLE.'.name AS assignee_name',
317
                'uc.username AS creator_username',
318
                'uc.name AS creator_name',
319
                CategoryModel::TABLE.'.description AS category_description',
320
                ColumnModel::TABLE.'.position AS column_position',
321
                ProjectModel::TABLE.'.default_swimlane'
322
            )
323
            ->join(UserModel::TABLE, 'id', 'owner_id', TaskModel::TABLE)
324
            ->left(UserModel::TABLE, 'uc', 'id', TaskModel::TABLE, 'creator_id')
325
            ->join(CategoryModel::TABLE, 'id', 'category_id', TaskModel::TABLE)
326
            ->join(ColumnModel::TABLE, 'id', 'column_id', TaskModel::TABLE)
327
            ->join(SwimlaneModel::TABLE, 'id', 'swimlane_id', TaskModel::TABLE)
328
            ->join(ProjectModel::TABLE, 'id', 'project_id', TaskModel::TABLE)
329
            ->eq(TaskModel::TABLE.'.id', $task_id)
330
            ->findOne();
331
    }
332
333
    /**
334
     * Get iCal query.
335
     *
336
     * @return \PicoDb\Table
337
     */
338 View Code Duplication
    public function getICalQuery()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
339
    {
340
        return $this->db->table(TaskModel::TABLE)
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
341
            ->left(UserModel::TABLE, 'ua', 'id', TaskModel::TABLE, 'owner_id')
342
            ->left(UserModel::TABLE, 'uc', 'id', TaskModel::TABLE, 'creator_id')
343
            ->columns(
344
                TaskModel::TABLE.'.*',
345
                'ua.email AS assignee_email',
346
                'ua.name AS assignee_name',
347
                'ua.username AS assignee_username',
348
                'uc.email AS creator_email',
349
                'uc.name AS creator_name',
350
                'uc.username AS creator_username'
351
            );
352
    }
353
354
    /**
355
     * Count all tasks for a given project and status.
356
     *
357
     * @param int   $project_id Project id
358
     * @param array $status     List of status id
359
     *
360
     * @return int
361
     */
362
    public function countByProjectId($project_id, array $status = [TaskModel::STATUS_OPEN, TaskModel::STATUS_CLOSED])
363
    {
364
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
365
                    ->table(TaskModel::TABLE)
366
                    ->eq('project_id', $project_id)
367
                    ->in('is_active', $status)
368
                    ->count();
369
    }
370
371
    /**
372
     * Count the number of tasks for a given column and status.
373
     *
374
     * @param int $project_id Project id
375
     * @param int $column_id  Column id
376
     *
377
     * @return int
378
     */
379 View Code Duplication
    public function countByColumnId($project_id, $column_id)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
380
    {
381
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
382
                    ->table(TaskModel::TABLE)
383
                    ->eq('project_id', $project_id)
384
                    ->eq('column_id', $column_id)
385
                    ->eq('is_active', 1)
386
                    ->count();
387
    }
388
389
    /**
390
     * Count the number of tasks for a given column and swimlane.
391
     *
392
     * @param int $project_id  Project id
393
     * @param int $column_id   Column id
394
     * @param int $swimlane_id Swimlane id
395
     *
396
     * @return int
397
     */
398 View Code Duplication
    public function countByColumnAndSwimlaneId($project_id, $column_id, $swimlane_id)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
399
    {
400
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
401
                    ->table(TaskModel::TABLE)
402
                    ->eq('project_id', $project_id)
403
                    ->eq('column_id', $column_id)
404
                    ->eq('swimlane_id', $swimlane_id)
405
                    ->eq('is_active', 1)
406
                    ->count();
407
    }
408
409
    /**
410
     * Return true if the task exists.
411
     *
412
     * @param int $task_id Task id
413
     *
414
     * @return bool
415
     */
416
    public function exists($task_id)
417
    {
418
        return $this->db->table(TaskModel::TABLE)->eq('id', $task_id)->exists();
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
419
    }
420
421
    /**
422
     * Get project token.
423
     *
424
     * @param int $task_id
425
     *
426
     * @return string
427
     */
428
    public function getProjectToken($task_id)
429
    {
430
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\TaskFinderModel>. 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...
431
            ->table(TaskModel::TABLE)
432
            ->eq(TaskModel::TABLE.'.id', $task_id)
433
            ->join(ProjectModel::TABLE, 'id', 'project_id')
434
            ->findOneColumn(ProjectModel::TABLE.'.token');
435
    }
436
}
437