Add explicit `return null;` statements
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / data / user / object / watch / UserObjectWatch.class.php
1 <?php
2
3 namespace wcf\data\user\object\watch;
4
5 use wcf\data\DatabaseObject;
6 use wcf\system\WCF;
7
8 /**
9 * Represents a watched object.
10 *
11 * @author Marcel Werk
12 * @copyright 2001-2019 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\Data\User\Object\Watch
15 *
16 * @property-read int $watchID unique id of the watched object
17 * @property-read int $objectTypeID id of the `com.woltlab.wcf.user.objectWatch` object type
18 * @property-read int $objectID id of the watched object of the specific object type
19 * @property-read int $userID id of the user watching the object
20 * @property-read int $notification is `1` if the user wants to receive notifications for the watched object, otherwise `0`
21 */
22 class UserObjectWatch extends DatabaseObject
23 {
24 /**
25 * Returns the UserObjectWatch with the given data or null if no such object
26 * exists.
27 *
28 * @param int $objectTypeID
29 * @param int $userID
30 * @param int $objectID
31 * @return UserObjectWatch|null
32 */
33 public static function getUserObjectWatch($objectTypeID, $userID, $objectID)
34 {
35 $sql = "SELECT *
36 FROM wcf" . WCF_N . "_user_object_watch
37 WHERE objectTypeID = ?
38 AND userID = ?
39 AND objectID = ?";
40 $statement = WCF::getDB()->prepareStatement($sql);
41 $statement->execute([$objectTypeID, $userID, $objectID]);
42 $row = $statement->fetch();
43 if (!$row) {
44 return null;
45 }
46
47 return new self(null, $row);
48 }
49 }