| Conditions | 4 |
| Paths | 5 |
| Total Lines | 54 |
| Code Lines | 42 |
| 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 |
||
| 30 | function xtubeShowBannerB($options) |
||
|
|
|||
| 31 | { |
||
| 32 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 33 | |||
| 34 | $block = []; |
||
| 35 | $time = time(); |
||
| 36 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 37 | $moduleHandler = xoops_getHandler('module'); |
||
| 38 | $xoopstubeModule = $moduleHandler->getByDirname($moduleDirName); |
||
| 39 | /** @var \XoopsConfigHandler $configHandler */ |
||
| 40 | $configHandler = xoops_getHandler('config'); |
||
| 41 | $xoopstubeModuleConfig = $configHandler->getConfigsByCat(0, $xoopstubeModule->getVar('mid')); |
||
| 42 | |||
| 43 | $result = $GLOBALS['xoopsDB']->query( |
||
| 44 | 'SELECT a.cid AS acid, a.title, a.client_id, a.banner_id, b.bid, b.cid, b.imptotal, b.impmade, b.clicks FROM ' |
||
| 45 | . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') |
||
| 46 | . ' a, ' |
||
| 47 | . $GLOBALS['xoopsDB']->prefix('banner') |
||
| 48 | . ' b WHERE (b.cid = a.client_id) OR (b.bid = a.banner_id) ORDER BY b.cid, b.bid, a.title ASC' |
||
| 49 | ); |
||
| 50 | |||
| 51 | while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
| 52 | $impmade = $myrow['impmade']; |
||
| 53 | $clicks = $myrow['clicks']; |
||
| 54 | $imptotal = $myrow['imptotal']; |
||
| 55 | $bannerload = []; |
||
| 56 | $result2 = $GLOBALS['xoopsDB']->query('SELECT name FROM ' . $GLOBALS['xoopsDB']->prefix('bannerclient') . ' WHERE cid=' . (int)$myrow['cid']); |
||
| 57 | $myclient = $GLOBALS['xoopsDB']->fetchArray($result2); |
||
| 58 | if (0 == $impmade) { |
||
| 59 | $percent = 0; |
||
| 60 | } else { |
||
| 61 | $percent = mb_substr(100 * $clicks / $impmade, 0, 5); |
||
| 62 | } |
||
| 63 | if (0 == $imptotal) { |
||
| 64 | $left = 'Unlimited'; |
||
| 65 | } else { |
||
| 66 | $left = (int)$imptotal - (int)$impmade; |
||
| 67 | } |
||
| 68 | $bannerload['cat'] = (int)$myrow['acid']; |
||
| 69 | $bannerload['bid'] = (int)$myrow['bid']; |
||
| 70 | $bannerload['cid'] = (int)$myrow['cid']; |
||
| 71 | $bannerload['imptotal'] = (int)$myrow['imptotal']; |
||
| 72 | $bannerload['impmade'] = (int)$myrow['impmade']; |
||
| 73 | $bannerload['impleft'] = $left; |
||
| 74 | $bannerload['clicks'] = (int)$myrow['clicks']; |
||
| 75 | $bannerload['client'] = $myclient['name']; |
||
| 76 | $bannerload['percent'] = $percent; |
||
| 77 | $bannerload['cattitle'] = $myrow['title']; |
||
| 78 | $bannerload['dirname'] = $xoopstubeModule->getVar('dirname'); |
||
| 79 | $block['banners'][] = $bannerload; |
||
| 80 | } |
||
| 81 | unset($_block_check_array); |
||
| 82 | |||
| 83 | return $block; |
||
| 84 | } |
||
| 97 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.