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 | |||
16 | /** |
||
17 | * Group Model. |
||
18 | */ |
||
19 | class GroupModel extends Model |
||
20 | { |
||
21 | /** |
||
22 | * SQL table name. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | const TABLE = 'groups'; |
||
27 | |||
28 | /** |
||
29 | * Get query to fetch all groups. |
||
30 | * |
||
31 | * @return \PicoDb\Table |
||
32 | */ |
||
33 | public function getQuery() |
||
34 | { |
||
35 | return $this->db->table(self::TABLE); |
||
0 ignored issues
–
show
|
|||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get a specific group by id. |
||
40 | * |
||
41 | * @param int $group_id |
||
42 | * |
||
43 | * @return array |
||
44 | */ |
||
45 | public function getById($group_id) |
||
46 | { |
||
47 | return $this->getQuery()->eq('id', $group_id)->findOne(); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Get a specific group by external id. |
||
52 | * |
||
53 | * @param int $external_id |
||
54 | * |
||
55 | * @return array |
||
56 | */ |
||
57 | public function getByExternalId($external_id) |
||
58 | { |
||
59 | return $this->getQuery()->eq('external_id', $external_id)->findOne(); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Get all groups. |
||
64 | * |
||
65 | * @return array |
||
66 | */ |
||
67 | public function getAll() |
||
68 | { |
||
69 | return $this->getQuery()->asc('name')->findAll(); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Search groups by name. |
||
74 | * |
||
75 | * @param string $input |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | public function search($input) |
||
80 | { |
||
81 | return $this->db->table(self::TABLE)->ilike('name', '%'.$input.'%')->asc('name')->findAll(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupModel> . 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. ![]() |
|||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Remove a group. |
||
86 | * |
||
87 | * @param int $group_id |
||
88 | * |
||
89 | * @return bool |
||
90 | */ |
||
91 | public function remove($group_id) |
||
92 | { |
||
93 | return $this->db->table(self::TABLE)->eq('id', $group_id)->remove(); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupModel> . 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. ![]() |
|||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Create a new group. |
||
98 | * |
||
99 | * @param string $name |
||
100 | * @param string $external_id |
||
101 | * |
||
102 | * @return int|bool |
||
103 | */ |
||
104 | public function create($name, $external_id = '') |
||
105 | { |
||
106 | return $this->db->table(self::TABLE)->persist([ |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupModel> . 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. ![]() |
|||
107 | 'name' => $name, |
||
108 | 'external_id' => $external_id, |
||
109 | ]); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * Update existing group. |
||
114 | * |
||
115 | * @param array $values |
||
116 | * |
||
117 | * @return bool |
||
118 | */ |
||
119 | public function update(array $values) |
||
120 | { |
||
121 | return $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupModel> . 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. ![]() |
|||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Get groupId from externalGroupId and create the group if not found. |
||
126 | * |
||
127 | * @param string $name |
||
128 | * @param string $external_id |
||
129 | * |
||
130 | * @return bool|int |
||
131 | */ |
||
132 | View Code Duplication | public function getOrCreateExternalGroupId($name, $external_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. ![]() |
|||
133 | { |
||
134 | $group_id = $this->db->table(self::TABLE)->eq('external_id', $external_id)->findOneColumn('id'); |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\GroupModel> . 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. ![]() |
|||
135 | |||
136 | if (empty($group_id)) { |
||
137 | $group_id = $this->create($name, $external_id); |
||
138 | } |
||
139 | |||
140 | return $group_id; |
||
141 | } |
||
142 | } |
||
143 |
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.