Passed
Branch master (cd0d6c)
by Michael
01:35
created

xdirectory.php ➔ b_waiting_xdirectory()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 37
Code Lines 25

Duplication

Lines 37
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
eloc 25
nc 8
nop 0
dl 37
loc 37
rs 8.5806
c 0
b 0
f 0
1
<?php
2
// This code is not tested
3
/**
4
 * @return array
5
 */
6
function b_waiting_xdirectory()
7
{
8
    /** @var \XoopsMySQLDatabase $xoopsDB */
9
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
10
    $ret     = [];
11
12
    // xdirectory links
13
    $block  = [];
14
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xdir_links') . ' WHERE status=0');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $xoopsDB->query('SELECT ...') . ' WHERE status=0') targeting XoopsMySQLDatabase::query() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
15
    if ($result) {
0 ignored issues
show
introduced by
$result is defined implicitly as null, thus it is always evaluated to false.
Loading history...
16
        $block['adminlink'] = XOOPS_URL . '/modules/xdirectory/admin/index.php?op=listNewLinks';
17
        list($block['pendingnum']) = $xoopsDB->fetchRow($result);
18
        $block['lang_linkname'] = _PI_WAITING_LINKS;
19
    }
20
    $ret[] = $block;
21
22
    // xdirectory broken
23
    $block  = [];
24
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xdir_broken'));
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $xoopsDB->query('SELECT ...>prefix('xdir_broken')) targeting XoopsMySQLDatabase::query() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
25
    if ($result) {
0 ignored issues
show
introduced by
$result is defined implicitly as null, thus it is always evaluated to false.
Loading history...
26
        $block['adminlink'] = XOOPS_URL . '/modules/xdirectory/admin/index.php?op=listBrokenLinks';
27
        list($block['pendingnum']) = $xoopsDB->fetchRow($result);
28
        $block['lang_linkname'] = _PI_WAITING_BROKENS;
29
    }
30
    $ret[] = $block;
31
32
    // xdirectory modreq
33
    $block  = [];
34
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xdir_mod'));
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $xoopsDB->query('SELECT ...DB->prefix('xdir_mod')) targeting XoopsMySQLDatabase::query() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
35
    if ($result) {
0 ignored issues
show
introduced by
$result is defined implicitly as null, thus it is always evaluated to false.
Loading history...
36
        $block['adminlink'] = XOOPS_URL . '/modules/xdirectory/admin/index.php?op=listModReq';
37
        list($block['pendingnum']) = $xoopsDB->fetchRow($result);
38
        $block['lang_linkname'] = _PI_WAITING_MODREQS;
39
    }
40
    $ret[] = $block;
41
42
    return $ret;
43
}
44