b_waiting_wordpress_0()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 10
nc 2
nop 1
dl 0
loc 18
rs 9.9332
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 * @param string $wp_num
5
 * @return array
6
 */
7
function b_waiting_wordpress_0($wp_num = '')
8
{
9
    /** @var \XoopsMySQLDatabase $xoopsDB */
10
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
11
    $ret     = [];
12
    $block   = [];
13
14
    // wordpress
15
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix("wp{$wp_num}_comments") . " WHERE comment_approved='0'");
16
    if ($result) {
17
        $block['adminlink'] = XOOPS_URL . "/modules/wordpress{$wp_num}/wp-admin/moderation.php";
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'] = sprintf(_PI_WAITING_WAITINGS_FMT, $wp_num);
20
    }
21
22
    $ret[] = $block;
23
24
    return $ret;
25
}
26
27
for ($i = 0; $i < 10; ++$i) {
28
    if (file_exists(XOOPS_ROOT_PATH . "/modules/wordpress{$i}/xoops_version.php")) {
29
        eval(
0 ignored issues
show
introduced by
The use of eval() is discouraged.
Loading history...
30
            ' function b_waiting_wordpress_' . ($i + 1) . '() {
31
            return b_waiting_wordpress_0(' . $i . ');
32
        }
33
        '
34
        );
35
    }
36
}
37