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

smartfaq.php ➔ b_waiting_smartfaq()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 47
Code Lines 32

Duplication

Lines 47
Ratio 100 %

Importance

Changes 0
Metric Value
cc 5
eloc 32
nc 16
nop 0
dl 47
loc 47
rs 8.5125
c 0
b 0
f 0
1
<?php
2
/**
3
 * XoopsFAQ plugin
4
 *
5
 * @author Marius Scurtescu <[email protected]>
6
 */
7
function b_waiting_smartfaq()
8
{
9
    /** @var \XoopsMySQLDatabase $xoopsDB */
10
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
11
    $ret     = [];
12
13
    // smartfaq submitted
14
    $block  = [];
15
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('smartfaq_faq') . ' WHERE status=4');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $xoopsDB->query('SELECT ...') . ' WHERE status=4') 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...
16
    if ($result) {
0 ignored issues
show
introduced by
$result is defined implicitly as null, thus it is always evaluated to false.
Loading history...
17
        $block['adminlink'] = XOOPS_URL . '/modules/smartfaq/admin/index.php?statussel=4';
18
        list($block['pendingnum']) = $xoopsDB->fetchRow($result);
19
        $block['lang_linkname'] = _PI_WAITING_SUBMITTED;
20
    }
21
    $ret[] = $block;
22
23
    // smartfaq asked
24
    $block  = [];
25
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('smartfaq_faq') . ' WHERE status=1');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $xoopsDB->query('SELECT ...') . ' WHERE status=1') 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...
26
    if ($result) {
0 ignored issues
show
introduced by
$result is defined implicitly as null, thus it is always evaluated to false.
Loading history...
27
        $block['adminlink'] = XOOPS_URL . '/modules/smartfaq/admin/index.php?statussel=1';
28
        list($block['pendingnum']) = $xoopsDB->fetchRow($result);
29
        $block['lang_linkname'] = _PI_WAITING_ASKED;
30
    }
31
    $ret[] = $block;
32
33
    // smartfaq new answer
34
    $block  = [];
35
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('smartfaq_faq') . ' WHERE status=6');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $xoopsDB->query('SELECT ...') . ' WHERE status=6') 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...
36
    if ($result) {
0 ignored issues
show
introduced by
$result is defined implicitly as null, thus it is always evaluated to false.
Loading history...
37
        $block['adminlink'] = XOOPS_URL . '/modules/smartfaq/admin/index.php?statussel=6';
38
        list($block['pendingnum']) = $xoopsDB->fetchRow($result);
39
        $block['lang_linkname'] = _PI_WAITING_NEWANSWERS;
40
    }
41
    $ret[] = $block;
42
43
    // smartfaq answered
44
    $block  = [];
45
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('smartfaq_faq') . ' WHERE status=3');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $xoopsDB->query('SELECT ...') . ' WHERE status=3') 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...
46
    if ($result) {
0 ignored issues
show
introduced by
$result is defined implicitly as null, thus it is always evaluated to false.
Loading history...
47
        $block['adminlink'] = XOOPS_URL . '/modules/smartfaq/admin/index.php?statussel=3';
48
        list($block['pendingnum']) = $xoopsDB->fetchRow($result);
49
        $block['lang_linkname'] = _PI_WAITING_ANSWERED;
50
    }
51
    $ret[] = $block;
52
53
    return $ret;
54
}
55