| Conditions | 6 |
| Paths | 32 |
| Total Lines | 61 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 22 | function b_waiting_animal() |
||
| 23 | { |
||
| 24 | $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
|
|
|||
| 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'; |
||
| 33 | [$block['pendingnum']] = $GLOBALS['xoopsDB']->fetchRow($result); |
||
| 34 | $block['lang_linkname'] = _PI_WAITING_WAITINGS; |
||
| 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 |