This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | use Jitamin\Foundation\Security\Role; |
||
16 | use Jitamin\Foundation\Security\Token; |
||
17 | |||
18 | /** |
||
19 | * Project model. |
||
20 | */ |
||
21 | class ProjectModel extends Model |
||
22 | { |
||
23 | /** |
||
24 | * SQL table name for projects. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | const TABLE = 'projects'; |
||
29 | |||
30 | /** |
||
31 | * Value for active project. |
||
32 | * |
||
33 | * @var int |
||
34 | */ |
||
35 | const ACTIVE = 1; |
||
36 | |||
37 | /** |
||
38 | * Value for inactive project. |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | const INACTIVE = 0; |
||
43 | |||
44 | /** |
||
45 | * Value for private project. |
||
46 | * |
||
47 | * @var int |
||
48 | */ |
||
49 | const TYPE_PRIVATE = 1; |
||
50 | |||
51 | /** |
||
52 | * Value for team project. |
||
53 | * |
||
54 | * @var int |
||
55 | */ |
||
56 | const TYPE_TEAM = 0; |
||
57 | |||
58 | /** |
||
59 | * Get a project by the id. |
||
60 | * |
||
61 | * @param int $project_id Project id |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | public function getById($project_id) |
||
66 | { |
||
67 | return $this->db->table(self::TABLE)->eq('id', $project_id)->findOne(); |
||
0 ignored issues
–
show
|
|||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Get a project by id with owner name. |
||
72 | * |
||
73 | * @param int $project_id Project id |
||
74 | * |
||
75 | * @return array |
||
76 | */ |
||
77 | View Code Duplication | public function getByIdWithOwner($project_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. ![]() |
|||
78 | { |
||
79 | return $this->db->table(self::TABLE) |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
80 | ->columns(self::TABLE.'.*', UserModel::TABLE.'.username AS owner_username', UserModel::TABLE.'.name AS owner_name') |
||
81 | ->eq(self::TABLE.'.id', $project_id) |
||
82 | ->join(UserModel::TABLE, 'id', 'owner_id') |
||
83 | ->findOne(); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Get a project by the name. |
||
88 | * |
||
89 | * @param string $name Project name |
||
90 | * |
||
91 | * @return array |
||
92 | */ |
||
93 | public function getByName($name) |
||
94 | { |
||
95 | return $this->db->table(self::TABLE)->eq('name', $name)->findOne(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Get a project by the identifier (code). |
||
100 | * |
||
101 | * @param string $identifier |
||
102 | * |
||
103 | * @return array|bool |
||
104 | */ |
||
105 | public function getByIdentifier($identifier) |
||
106 | { |
||
107 | if (empty($identifier)) { |
||
108 | return false; |
||
109 | } |
||
110 | |||
111 | return $this->db->table(self::TABLE)->eq('identifier', strtoupper($identifier))->findOne(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
112 | } |
||
113 | |||
114 | /** |
||
115 | * Fetch project data by using the token. |
||
116 | * |
||
117 | * @param string $token Token |
||
118 | * |
||
119 | * @return array|bool |
||
120 | */ |
||
121 | View Code Duplication | public function getByToken($token) |
|
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. ![]() |
|||
122 | { |
||
123 | if (empty($token)) { |
||
124 | return false; |
||
125 | } |
||
126 | |||
127 | return $this->db->table(self::TABLE)->eq('token', $token)->eq('is_public', 1)->findOne(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
128 | } |
||
129 | |||
130 | /** |
||
131 | * Return the first project from the database (no sorting). |
||
132 | * |
||
133 | * @return array |
||
134 | */ |
||
135 | public function getFirst() |
||
136 | { |
||
137 | return $this->db->table(self::TABLE)->findOne(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
138 | } |
||
139 | |||
140 | /** |
||
141 | * Return true if the project is private. |
||
142 | * |
||
143 | * @param int $project_id Project id |
||
144 | * |
||
145 | * @return bool |
||
146 | */ |
||
147 | public function isPrivate($project_id) |
||
148 | { |
||
149 | return $this->db->table(self::TABLE)->eq('id', $project_id)->eq('is_private', 1)->exists(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
150 | } |
||
151 | |||
152 | /** |
||
153 | * Get all projects. |
||
154 | * |
||
155 | * @return array |
||
156 | */ |
||
157 | public function getAll() |
||
158 | { |
||
159 | return $this->db->table(self::TABLE)->asc('name')->findAll(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
160 | } |
||
161 | |||
162 | /** |
||
163 | * Get all projects with given Ids. |
||
164 | * |
||
165 | * @param int[] $project_ids |
||
166 | * |
||
167 | * @return array |
||
168 | */ |
||
169 | public function getAllByIds(array $project_ids) |
||
170 | { |
||
171 | if (empty($project_ids)) { |
||
172 | return []; |
||
173 | } |
||
174 | |||
175 | return $this->db->table(self::TABLE)->in('id', $project_ids)->asc('name')->findAll(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
176 | } |
||
177 | |||
178 | /** |
||
179 | * Get all project ids. |
||
180 | * |
||
181 | * @return array |
||
182 | */ |
||
183 | public function getAllIds() |
||
184 | { |
||
185 | return $this->db->table(self::TABLE)->asc('name')->findAllByColumn('id'); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
186 | } |
||
187 | |||
188 | /** |
||
189 | * Return the list of all projects. |
||
190 | * |
||
191 | * @param bool $prepend If true, prepend to the list the value 'None' |
||
192 | * |
||
193 | * @return array |
||
194 | */ |
||
195 | public function getList($prepend = true) |
||
196 | { |
||
197 | if ($prepend) { |
||
198 | return [t('None')] + $this->db->hashtable(self::TABLE)->asc('name')->getAll('id', 'name'); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
199 | } |
||
200 | |||
201 | return $this->db->hashtable(self::TABLE)->asc('name')->getAll('id', 'name'); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
202 | } |
||
203 | |||
204 | /** |
||
205 | * Get all projects with all its data for a given status. |
||
206 | * |
||
207 | * @param int $status Project status: self::ACTIVE or self:INACTIVE |
||
208 | * |
||
209 | * @return array |
||
210 | */ |
||
211 | public function getAllByStatus($status) |
||
212 | { |
||
213 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
214 | ->table(self::TABLE) |
||
215 | ->asc('name') |
||
216 | ->eq('is_active', $status) |
||
217 | ->findAll(); |
||
218 | } |
||
219 | |||
220 | /** |
||
221 | * Get a list of project by status. |
||
222 | * |
||
223 | * @param int $status Project status: self::ACTIVE or self:INACTIVE |
||
224 | * |
||
225 | * @return array |
||
226 | */ |
||
227 | public function getListByStatus($status) |
||
228 | { |
||
229 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
230 | ->hashtable(self::TABLE) |
||
231 | ->asc('name') |
||
232 | ->eq('is_active', $status) |
||
233 | ->getAll('id', 'name'); |
||
234 | } |
||
235 | |||
236 | /** |
||
237 | * Return the number of projects by status. |
||
238 | * |
||
239 | * @param int $status Status: self::ACTIVE or self:INACTIVE |
||
240 | * |
||
241 | * @return int |
||
242 | */ |
||
243 | public function countByStatus($status) |
||
244 | { |
||
245 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
246 | ->table(self::TABLE) |
||
247 | ->eq('is_active', $status) |
||
248 | ->count(); |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * Gather some task metrics for a given project. |
||
253 | * |
||
254 | * @param int $project_id Project id |
||
255 | * |
||
256 | * @return array |
||
257 | */ |
||
258 | public function getTaskStats($project_id) |
||
259 | { |
||
260 | $stats = []; |
||
261 | $stats['nb_active_tasks'] = 0; |
||
262 | $columns = $this->columnModel->getAll($project_id); |
||
0 ignored issues
–
show
The property
columnModel does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
263 | $column_stats = $this->boardModel->getColumnStats($project_id); |
||
0 ignored issues
–
show
The property
boardModel does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
264 | |||
265 | View Code Duplication | foreach ($columns as &$column) { |
|
0 ignored issues
–
show
This code seems to be duplicated across 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. ![]() |
|||
266 | $column['nb_active_tasks'] = isset($column_stats[$column['id']]) ? $column_stats[$column['id']] : 0; |
||
267 | $stats['nb_active_tasks'] += $column['nb_active_tasks']; |
||
268 | } |
||
269 | |||
270 | $stats['columns'] = $columns; |
||
271 | $stats['nb_tasks'] = $this->taskFinderModel->countByProjectId($project_id); |
||
0 ignored issues
–
show
The property
taskFinderModel does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
272 | $stats['nb_inactive_tasks'] = $stats['nb_tasks'] - $stats['nb_active_tasks']; |
||
273 | |||
274 | return $stats; |
||
275 | } |
||
276 | |||
277 | /** |
||
278 | * Get stats for each column of a project. |
||
279 | * |
||
280 | * @param array $project |
||
281 | * |
||
282 | * @return array |
||
283 | */ |
||
284 | public function getColumnStats(array &$project) |
||
285 | { |
||
286 | $project['columns'] = $this->columnModel->getAll($project['id']); |
||
0 ignored issues
–
show
The property
columnModel does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
287 | $project['nb_active_tasks'] = 0; |
||
288 | $stats = $this->boardModel->getColumnStats($project['id']); |
||
0 ignored issues
–
show
The property
boardModel does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
289 | |||
290 | View Code Duplication | foreach ($project['columns'] as &$column) { |
|
0 ignored issues
–
show
This code seems to be duplicated across 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. ![]() |
|||
291 | $column['nb_tasks'] = isset($stats[$column['id']]) ? $stats[$column['id']] : 0; |
||
292 | $project['nb_active_tasks'] += $column['nb_tasks']; |
||
293 | } |
||
294 | |||
295 | return $project; |
||
296 | } |
||
297 | |||
298 | /** |
||
299 | * Apply column stats to a collection of projects (filter callback). |
||
300 | * |
||
301 | * @param array $projects |
||
302 | * |
||
303 | * @return array |
||
304 | */ |
||
305 | public function applyColumnStats(array $projects) |
||
306 | { |
||
307 | foreach ($projects as &$project) { |
||
308 | $this->getColumnStats($project); |
||
309 | } |
||
310 | |||
311 | return $projects; |
||
312 | } |
||
313 | |||
314 | /** |
||
315 | * Get project summary for a list of project. |
||
316 | * |
||
317 | * @param array $project_ids List of project id |
||
318 | * |
||
319 | * @return \PicoDb\Table |
||
320 | */ |
||
321 | public function getQueryColumnStats(array $project_ids) |
||
322 | { |
||
323 | if (empty($project_ids)) { |
||
324 | return $this->db->table(self::TABLE)->eq(self::TABLE.'.id', 0); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
325 | } |
||
326 | |||
327 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
328 | ->table(self::TABLE) |
||
329 | ->columns(self::TABLE.'.*', UserModel::TABLE.'.username AS owner_username', UserModel::TABLE.'.name AS owner_name') |
||
330 | ->join(UserModel::TABLE, 'id', 'owner_id') |
||
331 | ->in(self::TABLE.'.id', $project_ids) |
||
332 | ->callback([$this, 'applyColumnStats']); |
||
333 | } |
||
334 | |||
335 | /** |
||
336 | * Create a project. |
||
337 | * |
||
338 | * @param array $values Form values |
||
339 | * @param int $user_id User who create the project |
||
340 | * @param bool $add_user Automatically add the user |
||
341 | * |
||
342 | * @return int Project id |
||
343 | */ |
||
344 | public function create(array $values, $user_id = 0, $add_user = false) |
||
345 | { |
||
346 | $this->db->startTransaction(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
347 | |||
348 | $values['token'] = ''; |
||
349 | $values['last_modified'] = time(); |
||
350 | $values['is_private'] = empty($values['is_private']) ? 0 : 1; |
||
351 | $values['owner_id'] = $user_id; |
||
352 | |||
353 | if (!empty($values['identifier'])) { |
||
354 | $values['identifier'] = strtoupper($values['identifier']); |
||
355 | } |
||
356 | |||
357 | $this->helper->model->convertIntegerFields($values, ['priority_default', 'priority_start', 'priority_end']); |
||
0 ignored issues
–
show
The property
helper does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
358 | |||
359 | if (!$this->db->table(self::TABLE)->save($values)) { |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
360 | $this->db->cancelTransaction(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
361 | |||
362 | return false; |
||
363 | } |
||
364 | |||
365 | $project_id = $this->db->getLastId(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
366 | |||
367 | if (!$this->boardModel->create($project_id, $this->boardModel->getUserColumns())) { |
||
0 ignored issues
–
show
The property
boardModel does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
368 | $this->db->cancelTransaction(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
369 | |||
370 | return false; |
||
371 | } |
||
372 | |||
373 | if ($add_user && $user_id) { |
||
374 | $this->projectUserRoleModel->addUser($project_id, $user_id, Role::PROJECT_MANAGER); |
||
0 ignored issues
–
show
The property
projectUserRoleModel does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
375 | } |
||
376 | |||
377 | $this->categoryModel->createDefaultCategories($project_id); |
||
0 ignored issues
–
show
The property
categoryModel does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
378 | |||
379 | $this->db->closeTransaction(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
380 | |||
381 | return (int) $project_id; |
||
382 | } |
||
383 | |||
384 | /** |
||
385 | * Check if the project have been modified. |
||
386 | * |
||
387 | * @param int $project_id Project id |
||
388 | * @param int $timestamp Timestamp |
||
389 | * |
||
390 | * @return bool |
||
391 | */ |
||
392 | public function isModifiedSince($project_id, $timestamp) |
||
393 | { |
||
394 | return (bool) $this->db->table(self::TABLE) |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
395 | ->eq('id', $project_id) |
||
396 | ->gt('last_modified', $timestamp) |
||
397 | ->count(); |
||
398 | } |
||
399 | |||
400 | /** |
||
401 | * Update modification date. |
||
402 | * |
||
403 | * @param int $project_id Project id |
||
404 | * |
||
405 | * @return bool |
||
406 | */ |
||
407 | public function updateModificationDate($project_id) |
||
408 | { |
||
409 | return $this->db->table(self::TABLE)->eq('id', $project_id)->update([ |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
410 | 'last_modified' => time(), |
||
411 | ]); |
||
412 | } |
||
413 | |||
414 | /** |
||
415 | * Update a project. |
||
416 | * |
||
417 | * @param array $values Form values |
||
418 | * |
||
419 | * @return bool |
||
420 | */ |
||
421 | public function update(array $values) |
||
422 | { |
||
423 | if (!empty($values['identifier'])) { |
||
424 | $values['identifier'] = strtoupper($values['identifier']); |
||
425 | } |
||
426 | |||
427 | View Code Duplication | if (!empty($values['start_date'])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across 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. ![]() |
|||
428 | $values['start_date'] = $this->dateParser->getIsoDate($values['start_date']); |
||
0 ignored issues
–
show
The property
dateParser does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
429 | } |
||
430 | |||
431 | View Code Duplication | if (!empty($values['end_date'])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across 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. ![]() |
|||
432 | $values['end_date'] = $this->dateParser->getIsoDate($values['end_date']); |
||
0 ignored issues
–
show
The property
dateParser does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
433 | } |
||
434 | |||
435 | $this->helper->model->convertIntegerFields($values, ['priority_default', 'priority_start', 'priority_end']); |
||
0 ignored issues
–
show
The property
helper does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
436 | |||
437 | return $this->exists($values['id']) && |
||
438 | $this->db->table(self::TABLE)->eq('id', $values['id'])->save($values); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
439 | } |
||
440 | |||
441 | /** |
||
442 | * Remove a project. |
||
443 | * |
||
444 | * @param int $project_id Project id |
||
445 | * |
||
446 | * @return bool |
||
447 | */ |
||
448 | public function remove($project_id) |
||
449 | { |
||
450 | return $this->db->table(self::TABLE)->eq('id', $project_id)->remove(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
451 | } |
||
452 | |||
453 | /** |
||
454 | * Return true if the project exists. |
||
455 | * |
||
456 | * @param int $project_id Project id |
||
457 | * |
||
458 | * @return bool |
||
459 | */ |
||
460 | public function exists($project_id) |
||
461 | { |
||
462 | return $this->db->table(self::TABLE)->eq('id', $project_id)->exists(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
463 | } |
||
464 | |||
465 | /** |
||
466 | * Enable a project. |
||
467 | * |
||
468 | * @param int $project_id Project id |
||
469 | * |
||
470 | * @return bool |
||
471 | */ |
||
472 | View Code Duplication | public function enable($project_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. ![]() |
|||
473 | { |
||
474 | return $this->exists($project_id) && |
||
475 | $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
476 | ->table(self::TABLE) |
||
477 | ->eq('id', $project_id) |
||
478 | ->update(['is_active' => 1]); |
||
479 | } |
||
480 | |||
481 | /** |
||
482 | * Disable a project. |
||
483 | * |
||
484 | * @param int $project_id Project id |
||
485 | * |
||
486 | * @return bool |
||
487 | */ |
||
488 | View Code Duplication | public function disable($project_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. ![]() |
|||
489 | { |
||
490 | return $this->exists($project_id) && |
||
491 | $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
492 | ->table(self::TABLE) |
||
493 | ->eq('id', $project_id) |
||
494 | ->update(['is_active' => 0]); |
||
495 | } |
||
496 | |||
497 | /** |
||
498 | * Enable public access for a project. |
||
499 | * |
||
500 | * @param int $project_id Project id |
||
501 | * |
||
502 | * @return bool |
||
503 | */ |
||
504 | View Code Duplication | public function enablePublicAccess($project_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. ![]() |
|||
505 | { |
||
506 | return $this->exists($project_id) && |
||
507 | $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
508 | ->table(self::TABLE) |
||
509 | ->eq('id', $project_id) |
||
510 | ->save(['is_public' => 1, 'token' => Token::getToken()]); |
||
511 | } |
||
512 | |||
513 | /** |
||
514 | * Disable public access for a project. |
||
515 | * |
||
516 | * @param int $project_id Project id |
||
517 | * |
||
518 | * @return bool |
||
519 | */ |
||
520 | View Code Duplication | public function disablePublicAccess($project_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. ![]() |
|||
521 | { |
||
522 | return $this->exists($project_id) && |
||
523 | $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\ProjectModel> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
524 | ->table(self::TABLE) |
||
525 | ->eq('id', $project_id) |
||
526 | ->save(['is_public' => 0, 'token' => '']); |
||
527 | } |
||
528 | |||
529 | /** |
||
530 | * Get available views. |
||
531 | * |
||
532 | * @param bool $prepend Prepend a default value |
||
533 | * |
||
534 | * @return array |
||
535 | */ |
||
536 | public function getViews($prepend = false) |
||
537 | { |
||
538 | // Sorted by value |
||
539 | $views = [ |
||
540 | 'overview' => t('Overview'), |
||
541 | 'board' => t('Board'), |
||
542 | 'calendar' => t('Calendar'), |
||
543 | 'list' => t('List'), |
||
544 | 'gantt' => t('Gantt'), |
||
545 | ]; |
||
546 | |||
547 | if ($prepend) { |
||
548 | return ['' => t('Use default view')] + $views; |
||
549 | } |
||
550 | |||
551 | return $views; |
||
552 | } |
||
553 | } |
||
554 |
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.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.