b_waiting_mydownloads()   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
3
/**
4
 * @return array
5
 */
6
function b_waiting_mydownloads()
7
{
8
    /** @var \XoopsMySQLDatabase $xoopsDB */
9
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
10
    $ret     = [];
11
12
    // mydownloads links
13
    $block  = [];
14
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_downloads') . ' WHERE status=0');
15
    if ($result) {
16
        $block['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listNewDownloads';
17
        [$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

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