| Conditions | 12 |
| Paths | 36 |
| Total Lines | 27 |
| Code Lines | 14 |
| 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 |
||
| 84 | public function getAttributesHTML($attrs = null) { |
||
| 85 | $excludeKeys = (is_string($attrs)) ? func_get_args() : null; |
||
| 86 | |||
| 87 | if(!$attrs || is_string($attrs)) { |
||
| 88 | $attrs = $this->attributes; |
||
| 89 | } |
||
| 90 | |||
| 91 | // Remove empty or excluded values |
||
| 92 | foreach ($attrs as $key => $value) { |
||
| 93 | if ( |
||
| 94 | ($excludeKeys && in_array($key, $excludeKeys)) |
||
| 95 | || (!$value && $value !== 0 && $value !== '0') |
||
| 96 | ) { |
||
| 97 | unset($attrs[$key]); |
||
| 98 | continue; |
||
| 99 | } |
||
| 100 | } |
||
| 101 | |||
| 102 | // Create markkup |
||
| 103 | $parts = array(); |
||
| 104 | |||
| 105 | foreach($attrs as $name => $value) { |
||
| 106 | $parts[] = ($value === true) ? "{$name}=\"{$name}\"" : "{$name}=\"" . Convert::raw2att($value) . "\""; |
||
| 107 | } |
||
| 108 | |||
| 109 | return DBField::create_field('HTMLFragment', implode(' ', $parts)); |
||
| 110 | } |
||
| 111 | } |
||
| 112 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..