Jitamin /
jitamin
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 PDO; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Link model. |
||
| 19 | */ |
||
| 20 | class LinkModel extends Model |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * SQL table name. |
||
| 24 | * |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | const TABLE = 'links'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Get a link by id. |
||
| 31 | * |
||
| 32 | * @param int $link_id Link id |
||
| 33 | * |
||
| 34 | * @return array |
||
| 35 | */ |
||
| 36 | public function getById($link_id) |
||
| 37 | { |
||
| 38 | return $this->db->table(self::TABLE)->eq('id', $link_id)->findOne(); |
||
|
0 ignored issues
–
show
|
|||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Get a link by name. |
||
| 43 | * |
||
| 44 | * @param string $label |
||
| 45 | * |
||
| 46 | * @return array |
||
| 47 | */ |
||
| 48 | public function getByLabel($label) |
||
| 49 | { |
||
| 50 | return $this->db->table(self::TABLE)->eq('label', $label)->findOne(); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Get the opposite link id. |
||
| 55 | * |
||
| 56 | * @param int $link_id Link id |
||
| 57 | * |
||
| 58 | * @return int |
||
| 59 | */ |
||
| 60 | public function getOppositeLinkId($link_id) |
||
| 61 | { |
||
| 62 | return $this->db->table(self::TABLE)->eq('id', $link_id)->findOneColumn('opposite_id') ?: $link_id; |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Get all links. |
||
| 67 | * |
||
| 68 | * @return array |
||
| 69 | */ |
||
| 70 | public function getAll() |
||
| 71 | { |
||
| 72 | return $this->db->table(self::TABLE)->findAll(); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Get merged links. |
||
| 77 | * |
||
| 78 | * @return array |
||
| 79 | */ |
||
| 80 | public function getMergedList() |
||
| 81 | { |
||
| 82 | return $this->db |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 83 | ->execute(' |
||
| 84 | SELECT |
||
| 85 | links.id, links.label, opposite.label as opposite_label |
||
| 86 | FROM links |
||
| 87 | LEFT JOIN links AS opposite ON opposite.id=links.opposite_id |
||
| 88 | ') |
||
| 89 | ->fetchAll(PDO::FETCH_ASSOC); |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Get label list. |
||
| 94 | * |
||
| 95 | * @param int $exclude_id Exclude this link |
||
| 96 | * @param bool $prepend Prepend default value |
||
| 97 | * |
||
| 98 | * @return array |
||
| 99 | */ |
||
| 100 | public function getList($exclude_id = 0, $prepend = true) |
||
| 101 | { |
||
| 102 | $labels = $this->db->hashtable(self::TABLE)->neq('id', $exclude_id)->asc('id')->getAll('id', 'label'); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 103 | |||
| 104 | foreach ($labels as &$value) { |
||
| 105 | $value = t($value); |
||
| 106 | } |
||
| 107 | |||
| 108 | return $prepend ? [''] + $labels : $labels; |
||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Create a new link label. |
||
| 113 | * |
||
| 114 | * @param string $label |
||
| 115 | * @param string $opposite_label |
||
| 116 | * |
||
| 117 | * @return bool|int |
||
| 118 | */ |
||
| 119 | public function create($label, $opposite_label = '') |
||
| 120 | { |
||
| 121 | $this->db->startTransaction(); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 122 | |||
| 123 | if (!$this->db->table(self::TABLE)->insert(['label' => $label])) { |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 124 | $this->db->cancelTransaction(); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 125 | |||
| 126 | return false; |
||
| 127 | } |
||
| 128 | |||
| 129 | $label_id = $this->db->getLastId(); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 130 | |||
| 131 | if (!empty($opposite_label)) { |
||
| 132 | $this->db |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 133 | ->table(self::TABLE) |
||
| 134 | ->insert([ |
||
| 135 | 'label' => $opposite_label, |
||
| 136 | 'opposite_id' => $label_id, |
||
| 137 | ]); |
||
| 138 | |||
| 139 | $this->db |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 140 | ->table(self::TABLE) |
||
| 141 | ->eq('id', $label_id) |
||
| 142 | ->update([ |
||
| 143 | 'opposite_id' => $this->db->getLastId(), |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 144 | ]); |
||
| 145 | } |
||
| 146 | |||
| 147 | $this->db->closeTransaction(); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 148 | |||
| 149 | return (int) $label_id; |
||
| 150 | } |
||
| 151 | |||
| 152 | /** |
||
| 153 | * Update a link. |
||
| 154 | * |
||
| 155 | * @param array $values |
||
| 156 | * |
||
| 157 | * @return bool |
||
| 158 | */ |
||
| 159 | public function update(array $values) |
||
| 160 | { |
||
| 161 | return $this->db |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 162 | ->table(self::TABLE) |
||
| 163 | ->eq('id', $values['id']) |
||
| 164 | ->update([ |
||
| 165 | 'label' => $values['label'], |
||
| 166 | 'opposite_id' => $values['opposite_id'], |
||
| 167 | ]); |
||
| 168 | } |
||
| 169 | |||
| 170 | /** |
||
| 171 | * Remove a link a the relation to its opposite. |
||
| 172 | * |
||
| 173 | * @param int $link_id |
||
| 174 | * |
||
| 175 | * @return bool |
||
| 176 | */ |
||
| 177 | public function remove($link_id) |
||
| 178 | { |
||
| 179 | $this->db->table(self::TABLE)->eq('opposite_id', $link_id)->update(['opposite_id' => 0]); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 180 | |||
| 181 | return $this->db->table(self::TABLE)->eq('id', $link_id)->remove(); |
||
|
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\LinkModel>. 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. Loading history...
|
|||
| 182 | } |
||
| 183 | } |
||
| 184 |
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@propertyannotation 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.