| Conditions | 45 | 
| Paths | > 20000 | 
| Total Lines | 132 | 
| Code Lines | 91 | 
| 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  | 
            ||
| 96 | 	public static function recXmlPrint( $name, $value, $indent, $attributes = [] ) { | 
            ||
| 97 | $retval = '';  | 
            ||
| 98 | 		if ( $indent !== null ) { | 
            ||
| 99 | 			if ( $name !== null ) { | 
            ||
| 100 | $indent += 2;  | 
            ||
| 101 | }  | 
            ||
| 102 | $indstr = "\n" . str_repeat( ' ', $indent );  | 
            ||
| 103 | 		} else { | 
            ||
| 104 | $indstr = '';  | 
            ||
| 105 | }  | 
            ||
| 106 | |||
| 107 | 		if ( is_object( $value ) ) { | 
            ||
| 108 | $value = (array)$value;  | 
            ||
| 109 | }  | 
            ||
| 110 | 		if ( is_array( $value ) ) { | 
            ||
| 111 | $contentKey = isset( $value[ApiResult::META_CONTENT] )  | 
            ||
| 112 | ? $value[ApiResult::META_CONTENT]  | 
            ||
| 113 | : '*';  | 
            ||
| 114 | $subelementKeys = isset( $value[ApiResult::META_SUBELEMENTS] )  | 
            ||
| 115 | ? $value[ApiResult::META_SUBELEMENTS]  | 
            ||
| 116 | : [];  | 
            ||
| 117 | 			if ( isset( $value[ApiResult::META_BC_SUBELEMENTS] ) ) { | 
            ||
| 118 | $subelementKeys = array_merge(  | 
            ||
| 119 | $subelementKeys, $value[ApiResult::META_BC_SUBELEMENTS]  | 
            ||
| 120 | );  | 
            ||
| 121 | }  | 
            ||
| 122 | $preserveKeys = isset( $value[ApiResult::META_PRESERVE_KEYS] )  | 
            ||
| 123 | ? $value[ApiResult::META_PRESERVE_KEYS]  | 
            ||
| 124 | : [];  | 
            ||
| 125 | $indexedTagName = isset( $value[ApiResult::META_INDEXED_TAG_NAME] )  | 
            ||
| 126 | ? self::mangleName( $value[ApiResult::META_INDEXED_TAG_NAME], $preserveKeys )  | 
            ||
| 127 | : '_v';  | 
            ||
| 128 | $bcBools = isset( $value[ApiResult::META_BC_BOOLS] )  | 
            ||
| 129 | ? $value[ApiResult::META_BC_BOOLS]  | 
            ||
| 130 | : [];  | 
            ||
| 131 | $indexSubelements = isset( $value[ApiResult::META_TYPE] )  | 
            ||
| 132 | ? $value[ApiResult::META_TYPE] !== 'array'  | 
            ||
| 133 | : false;  | 
            ||
| 134 | |||
| 135 | $content = null;  | 
            ||
| 136 | $subelements = [];  | 
            ||
| 137 | $indexedSubelements = [];  | 
            ||
| 138 | 			foreach ( $value as $k => $v ) { | 
            ||
| 139 | 				if ( ApiResult::isMetadataKey( $k ) && !in_array( $k, $preserveKeys, true ) ) { | 
            ||
| 140 | continue;  | 
            ||
| 141 | }  | 
            ||
| 142 | |||
| 143 | $oldv = $v;  | 
            ||
| 144 | 				if ( is_bool( $v ) && !in_array( $k, $bcBools, true ) ) { | 
            ||
| 145 | $v = $v ? 'true' : 'false';  | 
            ||
| 146 | }  | 
            ||
| 147 | |||
| 148 | 				if ( $name !== null && $k === $contentKey ) { | 
            ||
| 149 | $content = $v;  | 
            ||
| 150 | 				} elseif ( is_int( $k ) ) { | 
            ||
| 151 | $indexedSubelements[$k] = $v;  | 
            ||
| 152 | 				} elseif ( is_array( $v ) || is_object( $v ) ) { | 
            ||
| 153 | $subelements[self::mangleName( $k, $preserveKeys )] = $v;  | 
            ||
| 154 | 				} elseif ( in_array( $k, $subelementKeys, true ) || $name === null ) { | 
            ||
| 155 | $subelements[self::mangleName( $k, $preserveKeys )] = [  | 
            ||
| 156 | 'content' => $v,  | 
            ||
| 157 | ApiResult::META_CONTENT => 'content',  | 
            ||
| 158 | ApiResult::META_TYPE => 'assoc',  | 
            ||
| 159 | ];  | 
            ||
| 160 | 				} elseif ( is_bool( $oldv ) ) { | 
            ||
| 161 | 					if ( $oldv ) { | 
            ||
| 162 | $attributes[self::mangleName( $k, $preserveKeys )] = '';  | 
            ||
| 163 | }  | 
            ||
| 164 | 				} elseif ( $v !== null ) { | 
            ||
| 165 | $attributes[self::mangleName( $k, $preserveKeys )] = $v;  | 
            ||
| 166 | }  | 
            ||
| 167 | }  | 
            ||
| 168 | |||
| 169 | 			if ( $content !== null ) { | 
            ||
| 170 | 				if ( $subelements || $indexedSubelements ) { | 
            ||
| 171 | $subelements[self::mangleName( $contentKey, $preserveKeys )] = [  | 
            ||
| 172 | 'content' => $content,  | 
            ||
| 173 | ApiResult::META_CONTENT => 'content',  | 
            ||
| 174 | ApiResult::META_TYPE => 'assoc',  | 
            ||
| 175 | ];  | 
            ||
| 176 | $content = null;  | 
            ||
| 177 | 				} elseif ( is_scalar( $content ) ) { | 
            ||
| 178 | // Add xml:space="preserve" to the element so XML parsers  | 
            ||
| 179 | // will leave whitespace in the content alone  | 
            ||
| 180 | $attributes += [ 'xml:space' => 'preserve' ];  | 
            ||
| 181 | }  | 
            ||
| 182 | }  | 
            ||
| 183 | |||
| 184 | 			if ( $content !== null ) { | 
            ||
| 185 | 				if ( is_scalar( $content ) ) { | 
            ||
| 186 | $retval .= $indstr . Xml::element( $name, $attributes, $content );  | 
            ||
| 187 | 				} else { | 
            ||
| 188 | 					if ( $name !== null ) { | 
            ||
| 189 | $retval .= $indstr . Xml::element( $name, $attributes, null );  | 
            ||
| 190 | }  | 
            ||
| 191 | $retval .= static::recXmlPrint( null, $content, $indent );  | 
            ||
| 192 | 					if ( $name !== null ) { | 
            ||
| 193 | $retval .= $indstr . Xml::closeElement( $name );  | 
            ||
| 194 | }  | 
            ||
| 195 | }  | 
            ||
| 196 | 			} elseif ( !$indexedSubelements && !$subelements ) { | 
            ||
| 197 | 				if ( $name !== null ) { | 
            ||
| 198 | $retval .= $indstr . Xml::element( $name, $attributes );  | 
            ||
| 199 | }  | 
            ||
| 200 | 			} else { | 
            ||
| 201 | 				if ( $name !== null ) { | 
            ||
| 202 | $retval .= $indstr . Xml::element( $name, $attributes, null );  | 
            ||
| 203 | }  | 
            ||
| 204 | 				foreach ( $subelements as $k => $v ) { | 
            ||
| 205 | $retval .= static::recXmlPrint( $k, $v, $indent );  | 
            ||
| 206 | }  | 
            ||
| 207 | 				foreach ( $indexedSubelements as $k => $v ) { | 
            ||
| 208 | $retval .= static::recXmlPrint( $indexedTagName, $v, $indent,  | 
            ||
| 209 | $indexSubelements ? [ '_idx' => $k ] : []  | 
            ||
| 210 | );  | 
            ||
| 211 | }  | 
            ||
| 212 | 				if ( $name !== null ) { | 
            ||
| 213 | $retval .= $indstr . Xml::closeElement( $name );  | 
            ||
| 214 | }  | 
            ||
| 215 | }  | 
            ||
| 216 | 		} else { | 
            ||
| 217 | // to make sure null value doesn't produce unclosed element,  | 
            ||
| 218 | // which is what Xml::element( $name, null, null ) returns  | 
            ||
| 219 | 			if ( $value === null ) { | 
            ||
| 220 | $retval .= $indstr . Xml::element( $name, $attributes );  | 
            ||
| 221 | 			} else { | 
            ||
| 222 | $retval .= $indstr . Xml::element( $name, $attributes, $value );  | 
            ||
| 223 | }  | 
            ||
| 224 | }  | 
            ||
| 225 | |||
| 226 | return $retval;  | 
            ||
| 227 | }  | 
            ||
| 228 | |||
| 302 | 
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.