| Conditions | 22 |
| Paths | 12288 |
| Total Lines | 78 |
| Code Lines | 64 |
| 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 declare(strict_types=1); |
||
| 84 | public function constructMarquee($uniqid = '') |
||
| 85 | { |
||
| 86 | // require_once XOOPS_ROOT_PATH . '/modules/marquee/class/Utility.php'; |
||
| 87 | $tblalign = ['top', 'bottom', 'middle']; |
||
| 88 | $tblbehaviour = ['scroll', 'slide', 'alternate']; |
||
| 89 | $tbldirection = ['right', 'left', 'up', 'down']; |
||
| 90 | $stop = 1 == $this->getVar('marquee_stoponmouseover') ? ' onmouseover="this.stop()" onmouseout="this.start()"' : ''; |
||
| 91 | $bgcolor = '' !== \trim($this->getVar('marquee_bgcolor')) ? " bgcolor='" . $this->getVar('marquee_bgcolor') . "'" : ''; |
||
| 92 | $height = 0 != $this->getVar('marquee_height') ? ' height=' . $this->getVar('marquee_height') : ''; |
||
| 93 | $hspace = 0 != $this->getVar('marquee_hspace') ? ' hspace=' . $this->getVar('marquee_hspace') : ''; |
||
| 94 | $width = '' !== \trim($this->getVar('marquee_width')) ? " width='" . $this->getVar('marquee_width') . "'" : ''; |
||
| 95 | $scrolldelay = 0 != $this->getVar('marquee_scrolldelay') ? ' scrolldelay=' . $this->getVar('marquee_scrolldelay') : ''; |
||
| 96 | $loop = 0 != $this->getVar('marquee_loop') ? ' loop=' . $this->getVar('marquee_loop') : " loop='infinite'"; |
||
| 97 | $vspace = 0 != $this->getVar('marquee_vspace') ? ' vspace=' . $this->getVar('marquee_vspace') : ''; |
||
| 98 | $scrollamount = 0 != $this->getVar('marquee_scrollamount') ? ' scrollamount=' . $this->getVar('marquee_scrollamount') : ''; |
||
| 99 | $br = ' - '; |
||
| 100 | if ($this->getVar('marquee_direction') > 1) { |
||
| 101 | $br = '<br>'; |
||
| 102 | } |
||
| 103 | $content = ''; |
||
| 104 | if ('fixed' !== $this->getVar('marquee_source')) { |
||
| 105 | require_once XOOPS_ROOT_PATH . '/modules/marquee/plugins/' . $this->getVar('marquee_source') . '.php'; |
||
| 106 | $function_name = 'b_marquee_' . $this->getVar('marquee_source'); // For example b_marquee_comments |
||
| 107 | if (\function_exists($function_name)) { |
||
| 108 | $limit = Utility::getModuleOption('itemscount'); |
||
| 109 | $dateFormat = Utility::getModuleOption('dateformat'); |
||
| 110 | $itemsSize = Utility::getModuleOption('itemssize'); |
||
| 111 | $retval = $function_name($limit, $dateFormat, $itemsSize); |
||
| 112 | if ($retval && \is_array($retval)) { |
||
| 113 | foreach ($retval as $onevalue) { |
||
| 114 | if (isset($onevalue['category']) && '' !== \xoops_trim($onevalue['category'])) { |
||
| 115 | $onevalue['category'] = ' - ' . $onevalue['category']; |
||
| 116 | } |
||
| 117 | if (isset($onevalue['link']) && '' !== \xoops_trim($onevalue['link'])) { |
||
| 118 | $onevalue['link'] = ' - ' . $onevalue['link']; |
||
| 119 | } |
||
| 120 | $content .= $onevalue['date'] . $onevalue['category'] . $onevalue['link'] . $br; |
||
| 121 | } |
||
| 122 | } |
||
| 123 | } |
||
| 124 | } else { |
||
| 125 | $content = $this->getVar('marquee_content'); |
||
| 126 | } |
||
| 127 | if (!Utility::isBot()) { // We are using the microsoft html tag |
||
| 128 | if ('dhtml' !== \mb_strtolower(Utility::getModuleOption('methodtouse'))) { |
||
| 129 | return "<marquee align='" |
||
| 130 | . $tblalign[$this->getVar('marquee_align')] |
||
| 131 | . "' behavior='" |
||
| 132 | . $tblbehaviour[$this->getVar('marquee_behaviour')] |
||
| 133 | . "' direction='" |
||
| 134 | . $tbldirection[$this->getVar('marquee_direction')] |
||
| 135 | . "' " |
||
| 136 | . $stop |
||
| 137 | . $scrollamount |
||
| 138 | . $bgcolor |
||
| 139 | . $height |
||
| 140 | . $hspace |
||
| 141 | . $width |
||
| 142 | . $scrolldelay |
||
| 143 | . $loop |
||
| 144 | . $vspace |
||
| 145 | . '>' |
||
| 146 | . $content |
||
| 147 | . '</marquee>'; |
||
| 148 | } // We are using the javascript method |
||
| 149 | $jscontent = "<script type=\"text/javascript\">\n"; |
||
| 150 | $jscontent .= "html$uniqid = '';\n"; |
||
| 151 | $jscontent .= "html$uniqid += '" . Utility::javascriptEscape($content) . "' ;\n"; |
||
| 152 | $jscontent .= "marquee$uniqid = new XbMarquee('marquee$uniqid', " . $this->getVar('marquee_height') . ', ' . $this->getVar('marquee_width') . ', ' . $this->getVar('marquee_scrollamount') . ', ' . $this->getVar('marquee_scrolldelay') . ", '" . $tbldirection[$this->getVar( |
||
| 153 | 'marquee_direction' |
||
| 154 | )] . "', '" . $tblbehaviour[$this->getVar('marquee_behaviour')] . "', html$uniqid);\n"; |
||
| 155 | $jscontent .= "init_$uniqid();\n"; |
||
| 156 | $jscontent .= "</script>\n"; |
||
| 157 | |||
| 158 | return $jscontent; |
||
| 159 | } |
||
| 160 | |||
| 161 | return $content; |
||
| 162 | } |
||
| 164 |