b_waiting_newbb()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 24
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 12
nc 3
nop 0
dl 0
loc 24
rs 9.8666
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 * @return array
5
 */
6
function b_waiting_newbb()
7
{
8
    /** @var \XoopsMySQLDatabase $xoopsDB */
9
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
10
    $ret     = [];
11
    $block   = [];
12
13
    // judge the version of newbb/
14
    if (!file_exists(XOOPS_ROOT_PATH . '/modules/newbb/polls.php')) {
15
        // newbb1
16
        return [];
17
    }
18
19
    // works with newbb2 or CBB 1.14
20
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('newbb_posts') . ' WHERE approved=0');
21
    if ($result) {
22
        $block['adminlink'] = XOOPS_URL . '/modules/newbb/admin/index.php';
23
        [$block['pendingnum']] = $xoopsDB->fetchRow($result);
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type true; however, parameter $result of XoopsMySQLDatabase::fetchRow() does only seem to accept mysqli_result, maybe add an additional type check? ( Ignorable by Annotation )

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

23
        [$block['pendingnum']] = $xoopsDB->fetchRow(/** @scrutinizer ignore-type */ $result);
Loading history...
24
        $block['lang_linkname'] = _PI_WAITING_SUBMITTED;
25
    }
26
27
    $ret[] = $block;
28
29
    return $ret;
30
}
31