| Conditions | 17 |
| Paths | 70 |
| Total Lines | 79 |
| 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 |
||
| 114 | protected function renderElement(BActiveRecord $element, $htmlOptions = array()) |
||
| 115 | {
|
||
| 116 | $id = Arr::get($htmlOptions, 'id', $element->getPrimaryKey()); |
||
| 117 | $htmlOptions['id'] = get_class($element).'-'.$id; |
||
| 118 | |||
| 119 | echo CHtml::tag('li', $htmlOptions, false, false);
|
||
| 120 | |||
| 121 | foreach($this->attributes as $key => $attributeOptions) |
||
| 122 | {
|
||
| 123 | if( is_null($attributeOptions) ) |
||
| 124 | continue; |
||
| 125 | |||
| 126 | $attribute = is_array($attributeOptions) ? $key : $attributeOptions; |
||
| 127 | $tag = Arr::get($attributeOptions, 'tag', 'input'); |
||
| 128 | $type = Arr::get($attributeOptions, 'type', 'text'); |
||
| 129 | |||
| 130 | $options = Arr::get($attributeOptions, 'htmlOptions', array('class' => 'span4'));
|
||
| 131 | |||
| 132 | if( isset($attributeOptions['class']) ) |
||
| 133 | $options['class'] = $attributeOptions['class']; |
||
| 134 | |||
| 135 | $options['name'] = "{$this->className}[{$id}][{$attribute}]";
|
||
| 136 | $options['value'] = $element->$attribute; |
||
| 137 | |||
| 138 | if( is_string($tag) ) |
||
| 139 | {
|
||
| 140 | switch($tag) |
||
| 141 | {
|
||
| 142 | case 'image': |
||
| 143 | echo CHtml::openTag('span', array('style' => 'display: inline-block;'));
|
||
| 144 | echo CHtml::openTag('span', array('style' => 'display: inline-block; width: 24px; margin-right: 7px;'));
|
||
| 145 | echo CHtml::image($element->getImage($attribute), '', Arr::get($attributeOptions, 'imageOptions', array('style' => 'max-width: 24px; max-height: 24px;')));
|
||
| 146 | echo CHtml::closeTag('span');
|
||
| 147 | echo CHtml::fileField($options['name'], $options['value']); |
||
| 148 | echo CHtml::closeTag('span');
|
||
| 149 | break; |
||
| 150 | |||
| 151 | case 'dropdownlist': |
||
| 152 | $defaultItem = Arr::cut($attributeOptions, 'defaultItem', array('' => 'Не задано'));
|
||
| 153 | $items = !empty($defaultItem) ? $defaultItem : array(); |
||
| 154 | $items = CMap::mergeArray($items, Arr::cut($attributeOptions, 'items', array())); |
||
| 155 | echo CHtml::dropDownList($options['name'], $options['value'], $items, $options); |
||
| 156 | break; |
||
| 157 | |||
| 158 | case 'textarea': |
||
| 159 | $options['class'] = isset($options['class']) ? $options['class'].' related-item-textarea' : ''; |
||
| 160 | echo CHtml::textArea($options['name'], $options['value'], $options); |
||
| 161 | break; |
||
| 162 | |||
| 163 | case 'color': |
||
| 164 | $options['type'] = 'color'; |
||
| 165 | $tag = 'input'; |
||
| 166 | $options['class'] = isset($options['class']) ? $options['class'].' input-color' : ''; |
||
| 167 | |||
| 168 | case 'input': |
||
| 169 | $options['type'] = Arr::get($options, 'type', $type); |
||
| 170 | |||
| 171 | if( $options['type'] == 'checkbox' ) |
||
| 172 | {
|
||
| 173 | $options['value'] = CheckBoxBehavior::CHECKED_VALUE; |
||
| 174 | if( !empty($element->$attribute) ) |
||
| 175 | $options['checked'] = 'checked'; |
||
| 176 | } |
||
| 177 | |||
| 178 | default: |
||
| 179 | echo CHtml::tag($tag, $options); |
||
| 180 | } |
||
| 181 | } |
||
| 182 | elseif( is_callable($tag) ) |
||
| 183 | {
|
||
| 184 | call_user_func_array($tag, array($element, $options)); |
||
| 185 | } |
||
| 186 | |||
| 187 | echo ' '; |
||
| 188 | } |
||
| 189 | |||
| 190 | $this->renderAjaxButton($id); |
||
| 191 | echo CHtml::closeTag('li');
|
||
| 192 | } |
||
| 193 | |||
| 254 | } |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.