Conditions | 7 |
Paths | 3 |
Total Lines | 51 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 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 declare(strict_types=1); |
||
25 | function b_news_topics_moderate() |
||
26 | { |
||
27 | // require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
||
28 | |||
29 | /** @var Helper $helper */ |
||
30 | if (!class_exists(Helper::class)) { |
||
31 | return false; |
||
32 | } |
||
33 | |||
34 | $helper = Helper::getInstance(); |
||
|
|||
35 | |||
36 | $block = []; |
||
37 | $dateformat = News\Utility::getModuleOption('dateformat'); |
||
38 | $infotips = News\Utility::getModuleOption('infotips'); |
||
39 | |||
40 | $storyarray = NewsStory:: getAllSubmitted(0, true, News\Utility::getModuleOption('restrictindex')); |
||
41 | if (count($storyarray) > 0) { |
||
42 | $block['lang_story_title'] = _MB_TITLE; |
||
43 | $block['lang_story_date'] = _MB_POSTED; |
||
44 | $block['lang_story_author'] = _MB_POSTER; |
||
45 | $block['lang_story_action'] = _MB_ACTION; |
||
46 | $block['lang_story_topic'] = _MB_TOPIC; |
||
47 | $myts = \MyTextSanitizer::getInstance(); |
||
48 | foreach ($storyarray as $newstory) { |
||
49 | $title = $newstory->title(); |
||
50 | $htmltitle = ''; |
||
51 | if ($infotips > 0) { |
||
52 | $story['infotips'] = News\Utility::makeInfotips($newstory->hometext()); |
||
53 | $htmltitle = ' title="' . $story['infotips'] . '"'; |
||
54 | } |
||
55 | |||
56 | if (!isset($title) || ('' == $title)) { |
||
57 | $linktitle = "<a href='" . XOOPS_URL . '/modules/news/index.php?op=edit&storyid=' . $newstory->storyid() . "' target='_blank'" . $htmltitle . '>' . _MD_NEWS_NOSUBJECT . '</a>'; |
||
58 | } else { |
||
59 | $linktitle = "<a href='" . XOOPS_URL . '/modules/news/submit.php?op=edit&storyid=' . $newstory->storyid() . "' target='_blank'" . $htmltitle . '>' . $title . '</a>'; |
||
60 | } |
||
61 | $story = []; |
||
62 | $story['title'] = $linktitle; |
||
63 | $story['date'] = formatTimestamp($newstory->created(), $dateformat); |
||
64 | $story['author'] = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $newstory->uid() . "'>" . $newstory->uname() . '</a>'; |
||
65 | $story['action'] = "<a href='" . XOOPS_URL . '/modules/news/admin/index.php?op=edit&storyid=' . $newstory->storyid() . "'>" . _EDIT . "</a> - <a href='" . XOOPS_URL . '/modules/news/admin/index.php?op=delete&storyid=' . $newstory->storyid() . "'>" . _MB_DELETE . '</a>'; |
||
66 | $story['topic_title'] = $newstory->topic_title(); |
||
67 | $story['topic_color'] = '#' . $myts->displayTarea($newstory->topic_color); |
||
68 | $block['picture'] = XOOPS_URL . '/uploads/news/image/' . $newstory->picture(); |
||
69 | $block['pictureinfo'] = $newstory->pictureinfo(); |
||
70 | $block['stories'][] = &$story; |
||
71 | unset($story); |
||
72 | } |
||
73 | } |
||
74 | |||
75 | return $block; |
||
76 | } |
||
90 |