| Conditions | 12 | 
| Paths | 192 | 
| Total Lines | 74 | 
| 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  | 
            ||
| 133 | public function render()  | 
            ||
| 134 |     { | 
            ||
| 135 | $items = $this->getButton();  | 
            ||
| 136 | $attributes = [  | 
            ||
| 137 | 'type' => 'submit',  | 
            ||
| 138 | 'class' => 'btn btn-sm btn-default ' . $items['primary']->getClasses(),  | 
            ||
| 139 | ];  | 
            ||
| 140 |         if (method_exists($items['primary'], 'getName')) { | 
            ||
| 141 | $attributes['name'] = $items['primary']->getName();  | 
            ||
| 142 | }  | 
            ||
| 143 |         if (method_exists($items['primary'], 'getValue')) { | 
            ||
| 144 | $attributes['value'] = $items['primary']->getValue();  | 
            ||
| 145 | }  | 
            ||
| 146 |         if (!empty($items['primary']->getOnClick())) { | 
            ||
| 147 | $attributes['onclick'] = $items['primary']->getOnClick();  | 
            ||
| 148 | }  | 
            ||
| 149 |         if (method_exists($items['primary'], 'getForm') && !empty($items['primary']->getForm())) { | 
            ||
| 150 | $attributes['form'] = $items['primary']->getForm();  | 
            ||
| 151 | }  | 
            ||
| 152 | $attributesString = '';  | 
            ||
| 153 |         foreach ($attributes as $key => $value) { | 
            ||
| 154 | $attributesString .= ' ' . htmlspecialchars($key) . '="' . htmlspecialchars($value) . '"';  | 
            ||
| 155 | }  | 
            ||
| 156 | $content = '  | 
            ||
| 157 | <div class="btn-group t3js-splitbutton">  | 
            ||
| 158 | <button' . $attributesString . '>  | 
            ||
| 159 |                 ' . $items['primary']->getIcon()->render('inline') . ' | 
            ||
| 160 | ' . htmlspecialchars($items['primary']->getTitle()) . '  | 
            ||
| 161 | </button>  | 
            ||
| 162 | <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">  | 
            ||
| 163 | <span class="sr-only">Toggle Dropdown</span>  | 
            ||
| 164 | </button>  | 
            ||
| 165 | <ul class="dropdown-menu">';  | 
            ||
| 166 | |||
| 167 | /** @var AbstractButton $option */  | 
            ||
| 168 |         foreach ($items['options'] as $option) { | 
            ||
| 169 |             if ($option instanceof InputButton) { | 
            ||
| 170 | // if the option is an InputButton we have to create a custom rendering  | 
            ||
| 171 | $optionAttributes = [  | 
            ||
| 172 | 'href' => '#',  | 
            ||
| 173 | 'data-name' => $option->getName(),  | 
            ||
| 174 | 'data-value' => $option->getValue(),  | 
            ||
| 175 | 'data-form' => $option->getForm()  | 
            ||
| 176 | ];  | 
            ||
| 177 | |||
| 178 |                 if (!empty($option->getClasses())) { | 
            ||
| 179 | $optionAttributes['class'] = $option->getClasses();  | 
            ||
| 180 | }  | 
            ||
| 181 |                 if (!empty($option->getOnClick())) { | 
            ||
| 182 | $optionAttributes['onclick'] = $option->getOnClick();  | 
            ||
| 183 | }  | 
            ||
| 184 |                 $optionAttributes['class'] = implode(' ', [$optionAttributes['class'] ?? '', 'dropdown-item']); | 
            ||
| 185 | $optionAttributesString = '';  | 
            ||
| 186 |                 foreach ($optionAttributes as $key => $value) { | 
            ||
| 187 | $optionAttributesString .= ' ' . htmlspecialchars($key) . '="' . htmlspecialchars($value) . '"';  | 
            ||
| 188 | }  | 
            ||
| 189 |                 $html =  '<a' . $optionAttributesString . '>' . $option->getIcon()->render('inline') . ' ' | 
            ||
| 190 | . htmlspecialchars($option->getTitle()) . '</a>';  | 
            ||
| 191 |             } else { | 
            ||
| 192 | // for any other kind of button we simply use what comes along (e.g. LinkButton)  | 
            ||
| 193 | $html = $option->render();  | 
            ||
| 194 | }  | 
            ||
| 195 | |||
| 196 | $content .= '  | 
            ||
| 197 | <li>  | 
            ||
| 198 | ' . $html . '  | 
            ||
| 199 | </li>  | 
            ||
| 200 | ';  | 
            ||
| 201 | }  | 
            ||
| 202 | $content .= '  | 
            ||
| 203 | </ul>  | 
            ||
| 204 | </div>  | 
            ||
| 205 | ';  | 
            ||
| 206 | return $content;  | 
            ||
| 207 | }  | 
            ||
| 219 |