Conditions | 12 |
Paths | 120 |
Total Lines | 35 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
38 | public function analyze(SendResult $response) |
||
39 | { |
||
40 | $result = $this->analyzeSimpleResponseErrorCodeAndMessageStatusCode($response); |
||
41 | |||
42 | $error = isset($response->responseObject->Error) ? $response->responseObject->Error : null; |
||
43 | $rawErrors = []; |
||
44 | |||
45 | if ($error === null) { |
||
46 | $rawErrors = isset($response->responseObject->Errors->Error) |
||
47 | ? $response->responseObject->Errors->Error |
||
48 | : []; |
||
49 | if (!is_array($rawErrors)) { |
||
50 | $rawErrors = [$rawErrors]; |
||
51 | } |
||
52 | } |
||
53 | |||
54 | if (is_array($error)) { |
||
55 | $rawErrors = array_merge($rawErrors, $error); |
||
56 | } elseif ($error !== null) { |
||
57 | $rawErrors[] = $error; |
||
58 | } |
||
59 | |||
60 | foreach ($rawErrors as $rawError) { |
||
61 | $result->setStatus(Result::STATUS_ERROR); |
||
62 | $result->messages[] = new NotOk( |
||
63 | isset($rawError->Code) ? $rawError->Code : '', |
||
64 | isset($rawError->DescText) ? $rawError->DescText : '' |
||
65 | ); |
||
66 | } |
||
67 | |||
68 | if ($response = isset($result->response->Response) ? $result->response->Response : null) { |
||
69 | $result->response = $response; |
||
70 | } |
||
71 | |||
72 | return $result; |
||
73 | } |
||
75 |