Complex classes like XmlrpcDecoder often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use XmlrpcDecoder, and based on these observations, apply Extract Interface, too.
| 1 | <?php namespace Comodojo\Xmlrpc; |
||
| 24 | class XmlrpcDecoder { |
||
| 25 | |||
| 26 | private $is_fault = false; |
||
| 27 | |||
| 28 | 21 | public function __construct() { |
|
| 33 | |||
| 34 | /** |
||
| 35 | * Decode an xmlrpc response |
||
| 36 | * |
||
| 37 | * @param string $response |
||
| 38 | * |
||
| 39 | * @return array |
||
| 40 | * |
||
| 41 | * @throws \Comodojo\Exception\XmlrpcException |
||
| 42 | */ |
||
| 43 | 12 | public function decodeResponse($response) { |
|
| 74 | |||
| 75 | 3 | public function isFault() { |
|
| 80 | |||
| 81 | /** |
||
| 82 | * Decode an xmlrpc request. |
||
| 83 | * |
||
| 84 | * Can handle single or multicall requests and return an array of: [method], [data] |
||
| 85 | * |
||
| 86 | * WARNING: in case of multicall, it will not throw any exception for an invalid |
||
| 87 | * boxcarred request; a null value will be placed instead of array(method,params). |
||
| 88 | * |
||
| 89 | * @param string $request |
||
| 90 | * |
||
| 91 | * @return array |
||
| 92 | * |
||
| 93 | * @throws \Comodojo\Exception\XmlrpcException |
||
| 94 | */ |
||
| 95 | 9 | public function decodeCall($request) { |
|
| 138 | |||
| 139 | /** |
||
| 140 | * Decode an xmlrpc multicall |
||
| 141 | * |
||
| 142 | * @param string $request |
||
| 143 | * |
||
| 144 | * @return array |
||
| 145 | * |
||
| 146 | * @throws \Comodojo\Exception\XmlrpcException |
||
| 147 | */ |
||
| 148 | public function decodeMulticall($request) { |
||
| 171 | |||
| 172 | /** |
||
| 173 | * Decode a value from xmlrpc data |
||
| 174 | * |
||
| 175 | * @param mixed $value |
||
| 176 | * |
||
| 177 | * @return mixed |
||
| 178 | * |
||
| 179 | * @throws \Comodojo\Exception\XmlrpcException |
||
| 180 | */ |
||
| 181 | 15 | private function decodeValue($value) { |
|
| 240 | |||
| 241 | /** |
||
| 242 | * Decode an XML-RPC <base64> element |
||
| 243 | */ |
||
| 244 | private function decodeBase($base64) { |
||
| 249 | |||
| 250 | /** |
||
| 251 | * Decode an XML-RPC <boolean> element |
||
| 252 | */ |
||
| 253 | 3 | private function decodeBool($boolean) { |
|
| 258 | |||
| 259 | /** |
||
| 260 | * Decode an XML-RPC <dateTime.iso8601> element |
||
| 261 | */ |
||
| 262 | private function decodeIso8601Datetime($date_time) { |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Decode an XML-RPC <double> element |
||
| 270 | */ |
||
| 271 | private function decodeDouble($double) { |
||
| 276 | |||
| 277 | /** |
||
| 278 | * Decode an XML-RPC <int> or <i4> element |
||
| 279 | */ |
||
| 280 | 6 | private function decodeInt($int) { |
|
| 285 | |||
| 286 | /** |
||
| 287 | * Decode an XML-RPC <string> |
||
| 288 | */ |
||
| 289 | 18 | private function decodeString($string) { |
|
| 294 | |||
| 295 | /** |
||
| 296 | * Decode an XML-RPC <nil/> |
||
| 297 | */ |
||
| 298 | private function decodeNil() { |
||
| 303 | |||
| 304 | /** |
||
| 305 | * Decode an XML-RPC <struct> |
||
| 306 | */ |
||
| 307 | 12 | private function decodeStruct($struct) { |
|
| 322 | |||
| 323 | /** |
||
| 324 | * Decode an XML-RPC <array> element |
||
| 325 | */ |
||
| 326 | 12 | private function decodeArray($array) { |
|
| 339 | |||
| 340 | /** |
||
| 341 | * Decode an XML-RPC multicall request (internal) |
||
| 342 | * @param \SimpleXMLElement $xml_data |
||
| 343 | */ |
||
| 344 | 6 | private function multicallDecode($xml_data) { |
|
| 369 | |||
| 370 | } |
||
| 371 |
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.