newbbGetRead()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 * NewBB,  the forum module for XOOPS project
5
 *
6
 * @copyright      XOOPS Project (https://xoops.org)
7
 * @license        GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
8
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
9
 * @since          4.00
10
 */
11
12
use XoopsModules\Newbb\{
13
    Helper,
14
    ReadHandler,
15
    ReadtopicHandler
16
};
17
18
/** @var Helper $helper */
19
/** @var ReadHandler $readHandler */
20
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
21
define('NEWBB_FUNCTIONS_READ_LOADED', true);
22
23
if (!defined('NEWBB_FUNCTIONS_READ')) {
24
    define('NEWBB_FUNCTIONS_READ', 1);
25
26
    /**
27
     * @param string $type
28
     * @param int    $item_id
29
     * @param int    $post_id
30
     * @param int|null   $uid
31
     * @return mixed
32
     */
33
    function newbbSetRead(string $type, int $item_id, int $post_id, ?int $uid = null)
34
    {
35
        $readHandler = Helper::getInstance()->getHandler('Read' . $type);
36
37
        return $readHandler->setRead($item_id, $post_id, $uid);
0 ignored issues
show
Bug introduced by
The method setRead() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPrivmessageHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        return $readHandler->/** @scrutinizer ignore-call */ setRead($item_id, $post_id, $uid);
Loading history...
38
    }
39
40
    /**
41
     * @param string $type
42
     * @param int $item_id
43
     * @param int|null   $uid
44
     * @return bool|int
45
     */
46
    function newbbGetRead(string $type, int $item_id, ?int $uid = null)
47
    {
48
        /** @var ReadHandler $readHandler */
49
        $readHandler = Helper::getInstance()->getHandler('Read' . $type);
50
51
        return $readHandler->getRead($item_id, $uid);
52
    }
53
54
    /**
55
     * @param int  $status
56
     * @param null $uid
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $uid is correct as it would always require null to be passed?
Loading history...
57
     * @return mixed
58
     */
59
    function newbbSetReadforum(int $status = 0, $uid = null)
60
    {
61
        /** @var ReadHandler $readforumHandler */
62
        $readforumHandler = Helper::getInstance()->getHandler('Readforum');
63
64
        return $readforumHandler->setReadItems($status, $uid);
65
    }
66
67
    /**
68
     * @param int  $status
69
     * @param int  $forum_id
70
     * @param null $uid
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $uid is correct as it would always require null to be passed?
Loading history...
71
     * @return mixed
72
     */
73
    function newbbSetReadTopic(int $status = 0, int $forum_id = 0, $uid = null)
74
    {
75
        /** @var ReadHandler $readTopicHandler */
76
        $readTopicHandler = Helper::getInstance()->getHandler('Readtopic');
77
78
        return $readTopicHandler->setReadItems($status, $forum_id, $uid);
79
    }
80
81
    /**
82
     * @param string $type
83
     * @param array  $items
84
     * @param int|null   $uid
85
     * @return array|null
86
     */
87
    function newbbIsRead(string $type, array $items, ?int $uid = null): ?array
88
    {
89
        /** @var ReadHandler $readHandler */
90
        $readHandler = Helper::getInstance()->getHandler('Read' . $type);
91
92
        return $readHandler->isReadItems($items, $uid);
93
    }
94
}
95