b_waiting_animal()   B
last analyzed

Complexity

Conditions 6
Paths 32

Size

Total Lines 61
Code Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 6
eloc 38
nc 32
nop 0
dl 0
loc 61
rs 8.6897
c 2
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * animal module for xoops
14
 *
15
 * @copyright       The TXMod XOOPS Project http://sourceforge.net/projects/thmod/
16
 * @copyright       XOOPS Project (https://xoops.org)
17
 * @license         GPL 2.0 or later
18
 * @package         animal
19
 * @since           2.5.x
20
 * @author          XOOPS Development Team ( [email protected] ) - ( https://xoops.org )
21
 */
22
function b_waiting_animal()
23
{
24
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
0 ignored issues
show
Unused Code introduced by
The assignment to $xoopsDB is dead and can be removed.
Loading history...
25
    $ret     = [];
26
27
    // waiting pedigree_trash
28
    $block = [];
29
30
    $result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash') . ' WHERE pedigree_trash_waiting=1');
31
    if ($result) {
32
        $block['adminlink'] = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/pedigree_trash.php?op=listWaiting';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $xoopsModule seems to be never defined.
Loading history...
33
        [$block['pendingnum']] = $GLOBALS['xoopsDB']->fetchRow($result);
34
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
0 ignored issues
show
Bug introduced by
The constant _PI_WAITING_WAITINGS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
35
    }
36
    $ret[] = $block;
37
38
    // waiting mod_owner
39
    $block = [];
40
41
    $result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_owner') . ' WHERE owner_waiting=1');
42
    if ($result) {
43
        $block['adminlink'] = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/owner.php?op=listWaiting';
44
        [$block['pendingnum']] = $GLOBALS['xoopsDB']->fetchRow($result);
45
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
46
    }
47
    $ret[] = $block;
48
49
    // waiting pedigree_temp
50
    $block = [];
51
52
    $result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_temp') . ' WHERE pedigree_temp_waiting=1');
53
    if ($result) {
54
        $block['adminlink'] = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/pedigree_temp.php?op=listWaiting';
55
        [$block['pendingnum']] = $GLOBALS['xoopsDB']->fetchRow($result);
56
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
57
    }
58
    $ret[] = $block;
59
60
    // waiting pedigree
61
    $block = [];
62
63
    $result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE pedigree_waiting=1');
64
    if ($result) {
65
        $block['adminlink'] = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/pedigree.php?op=listWaiting';
66
        [$block['pendingnum']] = $GLOBALS['xoopsDB']->fetchRow($result);
67
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
68
    }
69
    $ret[] = $block;
70
71
    // waiting pedigree_fields
72
    $block = [];
73
74
    $result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_fields') . ' WHERE pedigree_fields_waiting=1');
75
    if ($result) {
76
        $block['adminlink'] = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/pedigree_fields.php?op=listWaiting';
77
        [$block['pendingnum']] = $GLOBALS['xoopsDB']->fetchRow($result);
78
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
79
    }
80
    $ret[] = $block;
81
82
    return $ret;
83
}
84