b_waiting_addresses()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 37
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 24
nc 8
nop 0
dl 0
loc 37
rs 9.536
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
// This code is not tested
3
4
/**
5
 * @return array
6
 */
7
function b_waiting_addresses()
8
{
9
    /** @var \XoopsMySQLDatabase $xoopsDB */
10
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
11
    $ret     = [];
12
13
    // addresses links
14
    $block  = [];
15
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('addresses_links') . ' WHERE status=0');
16
    if ($result) {
17
        $block['adminlink'] = XOOPS_URL . '/modules/addresses/admin/index.php?op=listNewLinks';
18
        [$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

18
        [$block['pendingnum']] = $xoopsDB->fetchRow(/** @scrutinizer ignore-type */ $result);
Loading history...
19
        $block['lang_linkname'] = _PI_WAITING_LINKS;
20
    }
21
    $ret[] = $block;
22
23
    // addresses broken
24
    $block  = [];
25
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('addresses_broken'));
26
    if ($result) {
27
        $block['adminlink'] = XOOPS_URL . '/modules/addresses/admin/index.php?op=listBrokenLinks';
28
        [$block['pendingnum']] = $xoopsDB->fetchRow($result);
29
        $block['lang_linkname'] = _PI_WAITING_BROKENS;
30
    }
31
    $ret[] = $block;
32
33
    // addresses modreq
34
    $block  = [];
35
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('addresses_mod'));
36
    if ($result) {
37
        $block['adminlink'] = XOOPS_URL . '/modules/addresses/admin/index.php?op=listModReq';
38
        [$block['pendingnum']] = $xoopsDB->fetchRow($result);
39
        $block['lang_linkname'] = _PI_WAITING_MODREQS;
40
    }
41
    $ret[] = $block;
42
43
    return $ret;
44
}
45