Issues (3948)

Security Analysis    not enabled

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

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

app/Models/SubtaskTimeTrackingModel.php (23 issues)

Upgrade to new PHP Analysis Engine

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

1
<?php
2
3
/*
4
 * This file is part of Jitamin.
5
 *
6
 * Copyright (C) Jitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Jitamin\Model;
13
14
use DateTime;
15
use Jitamin\Foundation\Database\Model;
16
17
/**
18
 * Subtask time tracking.
19
 */
20
class SubtaskTimeTrackingModel extends Model
21
{
22
    /**
23
     * SQL table name.
24
     *
25
     * @var string
26
     */
27
    const TABLE = 'subtask_time_tracking';
28
29
    /**
30
     * Get query to check if a timer is started for the given user and subtask.
31
     *
32
     * @param int $user_id User id
33
     *
34
     * @return string
35
     */
36
    public function getTimerQuery($user_id)
37
    {
38
        return sprintf(
39
            "SELECT %s FROM %s WHERE %s='%d' AND %s='0' AND %s=%s LIMIT 1",
40
            $this->db->escapeIdentifier('start'),
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
41
            $this->db->escapeIdentifier(self::TABLE),
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
42
            $this->db->escapeIdentifier('user_id'),
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
43
            $user_id,
44
            $this->db->escapeIdentifier('end'),
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
45
            $this->db->escapeIdentifier('subtask_id'),
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
46
            SubtaskModel::TABLE.'.id'
47
        );
48
    }
49
50
    /**
51
     * Get query for user timesheet (pagination).
52
     *
53
     * @param int $user_id User id
54
     *
55
     * @return \PicoDb\Table
56
     */
57
    public function getUserQuery($user_id)
58
    {
59
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
60
                    ->table(self::TABLE)
61
                    ->columns(
62
                        self::TABLE.'.id',
63
                        self::TABLE.'.subtask_id',
64
                        self::TABLE.'.end',
65
                        self::TABLE.'.start',
66
                        self::TABLE.'.time_spent',
67
                        SubtaskModel::TABLE.'.task_id',
68
                        SubtaskModel::TABLE.'.title AS subtask_title',
69
                        TaskModel::TABLE.'.title AS task_title',
70
                        TaskModel::TABLE.'.project_id',
71
                        TaskModel::TABLE.'.color_id'
72
                    )
73
                    ->join(SubtaskModel::TABLE, 'id', 'subtask_id')
74
                    ->join(TaskModel::TABLE, 'id', 'task_id', SubtaskModel::TABLE)
75
                    ->eq(self::TABLE.'.user_id', $user_id);
76
    }
77
78
    /**
79
     * Get query for task timesheet (pagination).
80
     *
81
     * @param int $task_id Task id
82
     *
83
     * @return \PicoDb\Table
84
     */
85
    public function getTaskQuery($task_id)
86
    {
87
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
88
                    ->table(self::TABLE)
89
                    ->columns(
90
                        self::TABLE.'.id',
91
                        self::TABLE.'.subtask_id',
92
                        self::TABLE.'.end',
93
                        self::TABLE.'.start',
94
                        self::TABLE.'.time_spent',
95
                        self::TABLE.'.user_id',
96
                        SubtaskModel::TABLE.'.task_id',
97
                        SubtaskModel::TABLE.'.title AS subtask_title',
98
                        TaskModel::TABLE.'.project_id',
99
                        UserModel::TABLE.'.username',
100
                        UserModel::TABLE.'.name AS user_fullname'
101
                    )
102
                    ->join(SubtaskModel::TABLE, 'id', 'subtask_id')
103
                    ->join(TaskModel::TABLE, 'id', 'task_id', SubtaskModel::TABLE)
104
                    ->join(UserModel::TABLE, 'id', 'user_id', self::TABLE)
105
                    ->eq(TaskModel::TABLE.'.id', $task_id);
106
    }
107
108
    /**
109
     * Get query for project timesheet (pagination).
110
     *
111
     * @param int $project_id Project id
112
     *
113
     * @return \PicoDb\Table
114
     */
115
    public function getProjectQuery($project_id)
116
    {
117
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
118
                    ->table(self::TABLE)
119
                    ->columns(
120
                        self::TABLE.'.id',
121
                        self::TABLE.'.subtask_id',
122
                        self::TABLE.'.end',
123
                        self::TABLE.'.start',
124
                        self::TABLE.'.time_spent',
125
                        self::TABLE.'.user_id',
126
                        SubtaskModel::TABLE.'.task_id',
127
                        SubtaskModel::TABLE.'.title AS subtask_title',
128
                        TaskModel::TABLE.'.project_id',
129
                        TaskModel::TABLE.'.color_id',
130
                        UserModel::TABLE.'.username',
131
                        UserModel::TABLE.'.name AS user_fullname'
132
                    )
133
                    ->join(SubtaskModel::TABLE, 'id', 'subtask_id')
134
                    ->join(TaskModel::TABLE, 'id', 'task_id', SubtaskModel::TABLE)
135
                    ->join(UserModel::TABLE, 'id', 'user_id', self::TABLE)
136
                    ->eq(TaskModel::TABLE.'.project_id', $project_id)
137
                    ->asc(self::TABLE.'.id');
138
    }
139
140
    /**
141
     * Get all recorded time slots for a given user.
142
     *
143
     * @param int $user_id User id
144
     *
145
     * @return array
146
     */
147
    public function getUserTimesheet($user_id)
148
    {
149
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
150
                    ->table(self::TABLE)
151
                    ->eq('user_id', $user_id)
152
                    ->findAll();
153
    }
154
155
    /**
156
     * Return true if a timer is started for this use and subtask.
157
     *
158
     * @param int $subtask_id
159
     * @param int $user_id
160
     *
161
     * @return bool
162
     */
163
    public function hasTimer($subtask_id, $user_id)
164
    {
165
        return $this->db->table(self::TABLE)->eq('subtask_id', $subtask_id)->eq('user_id', $user_id)->eq('end', 0)->exists();
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
166
    }
167
168
    /**
169
     * Start or stop timer according to subtask status.
170
     *
171
     * @param int $subtask_id
172
     * @param int $user_id
173
     * @param int $status
174
     *
175
     * @return bool
176
     */
177
    public function toggleTimer($subtask_id, $user_id, $status)
178
    {
179
        if ($this->settingModel->get('subtask_time_tracking') == 1) {
0 ignored issues
show
The property settingModel does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
180
            if ($status == SubtaskModel::STATUS_INPROGRESS) {
181
                return $this->subtaskTimeTrackingModel->logStartTime($subtask_id, $user_id);
0 ignored issues
show
The property subtaskTimeTrackingModel does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
182
            } elseif ($status == SubtaskModel::STATUS_DONE) {
183
                return $this->subtaskTimeTrackingModel->logEndTime($subtask_id, $user_id);
0 ignored issues
show
The property subtaskTimeTrackingModel does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
184
            }
185
        }
186
187
        return false;
188
    }
189
190
    /**
191
     * Log start time.
192
     *
193
     * @param int $subtask_id
194
     * @param int $user_id
195
     *
196
     * @return bool
197
     */
198
    public function logStartTime($subtask_id, $user_id)
199
    {
200
        return
201
            !$this->hasTimer($subtask_id, $user_id) &&
202
            $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
203
                ->table(self::TABLE)
204
                ->insert(['subtask_id' => $subtask_id, 'user_id' => $user_id, 'start' => time(), 'end' => 0]);
205
    }
206
207
    /**
208
     * Log end time.
209
     *
210
     * @param int $subtask_id
211
     * @param int $user_id
212
     *
213
     * @return bool
214
     */
215
    public function logEndTime($subtask_id, $user_id)
216
    {
217
        $time_spent = $this->getTimeSpent($subtask_id, $user_id);
218
219
        if ($time_spent > 0) {
220
            $this->updateSubtaskTimeSpent($subtask_id, $time_spent);
221
        }
222
223
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
224
                    ->table(self::TABLE)
225
                    ->eq('subtask_id', $subtask_id)
226
                    ->eq('user_id', $user_id)
227
                    ->eq('end', 0)
228
                    ->update([
229
                        'end'        => time(),
230
                        'time_spent' => $time_spent,
231
                    ]);
232
    }
233
234
    /**
235
     * Calculate the time spent when the clock is stopped.
236
     *
237
     * @param int $subtask_id
238
     * @param int $user_id
239
     *
240
     * @return float
241
     */
242
    public function getTimeSpent($subtask_id, $user_id)
243
    {
244
        $hook = 'model:subtask-time-tracking:calculate:time-spent';
245
        $start_time = $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
246
            ->table(self::TABLE)
247
            ->eq('subtask_id', $subtask_id)
248
            ->eq('user_id', $user_id)
249
            ->eq('end', 0)
250
            ->findOneColumn('start');
251
252
        if (empty($start_time)) {
253
            return 0;
254
        }
255
256
        $end = new DateTime();
257
        $start = new DateTime();
258
        $start->setTimestamp($start_time);
259
260
        if ($this->hook->exists($hook)) {
0 ignored issues
show
The property hook does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
261
            return $this->hook->first($hook, [
0 ignored issues
show
The property hook does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
262
                'user_id' => $user_id,
263
                'start'   => $start,
264
                'end'     => $end,
265
            ]);
266
        }
267
268
        return $this->dateParser->getHours($start, $end);
0 ignored issues
show
The property dateParser does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
269
    }
270
271
    /**
272
     * Update subtask time spent.
273
     *
274
     * @param int   $subtask_id
275
     * @param float $time_spent
276
     *
277
     * @return bool
278
     */
279
    public function updateSubtaskTimeSpent($subtask_id, $time_spent)
280
    {
281
        $subtask = $this->subtaskModel->getById($subtask_id);
0 ignored issues
show
The property subtaskModel does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
282
283
        return $this->subtaskModel->update([
0 ignored issues
show
The property subtaskModel does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
284
            'id'         => $subtask['id'],
285
            'time_spent' => $subtask['time_spent'] + $time_spent,
286
            'task_id'    => $subtask['task_id'],
287
        ], false);
288
    }
289
290
    /**
291
     * Update task time tracking based on subtasks time tracking.
292
     *
293
     * @param int $task_id Task id
294
     *
295
     * @return bool
296
     */
297
    public function updateTaskTimeTracking($task_id)
298
    {
299
        $values = $this->calculateSubtaskTime($task_id);
300
301
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
302
                    ->table(TaskModel::TABLE)
303
                    ->eq('id', $task_id)
304
                    ->update($values);
305
    }
306
307
    /**
308
     * Sum time spent and time estimated for all subtasks.
309
     *
310
     * @param int $task_id Task id
311
     *
312
     * @return array
313
     */
314
    public function calculateSubtaskTime($task_id)
315
    {
316
        return $this->db
0 ignored issues
show
The property db does not exist on object<Jitamin\Model\SubtaskTimeTrackingModel>. Since you implemented __get, maybe consider adding a @property annotation.

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

<?php

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

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

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

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

}

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

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

See also the PhpDoc documentation for @property.

Loading history...
317
                    ->table(SubtaskModel::TABLE)
318
                    ->eq('task_id', $task_id)
319
                    ->columns(
320
                        'SUM(time_spent) AS time_spent',
321
                        'SUM(time_estimated) AS time_estimated'
322
                    )
323
                    ->findOne();
324
    }
325
}
326