waiting.plugin.php ➔ b_waiting_randomquote()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits of
4
 supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit
6
 authors.
7
8
 This program is distributed in the hope that it will be useful, but
9
 WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * Module: RandomQuote
14
 *
15
 * @category        Module
16
 * @package         randomquote
17
 * @author          XOOPS Module Development Team
18
 * @author          Mamba
19
 * @copyright       {@link https://xoops.org 2001-2016 XOOPS Project}
20
 * @license         {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
21
 * @link            https://xoops.org XOOPS
22
 * @since           2.00
23
 */
24
25
function b_waiting_randomquote()
26
{
27
    $moduleDirName = basename(dirname(__DIR__));
28
    require_once $GLOBALS['xoops']->path("/modules/{$moduleDirName}/class/constants.php");
29
30
    $xoopsDB       = XoopsDatabaseFactory::getDatabaseConnection();
0 ignored issues
show
Unused Code introduced by
$xoopsDB is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
31
    $block         = array();
32
    $quotesHandler = xoops_getModuleHandler('quotes', $moduleDirName);
33
34
    // quotes waiting approval
35
    $result = $quotesHandler->getCount(new Criteria('quote_status', RandomquoteConstants::STATUS_WAITING));
36
    if ($result) {
37
        $block = array('adminlink'     => $GLOBALS['xoops']->url("www/modules/{$moduleDirName}/admin/main.php?op=list&status=" . RandomquoteConstants::STATUS_WAITING),
38
                       'pendingnum'    => (int)$result,
39
                       'lang_linkname' => _PI_WAITING_WAITINGS);
40
    }
41
42
    return $block;
43
}
44