| Conditions | 11 |
| Paths | 99 |
| Total Lines | 62 |
| Code Lines | 28 |
| Lines | 8 |
| Ratio | 12.9 % |
| Tests | 0 |
| CRAP Score | 132 |
| Changes | 7 | ||
| 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 |
||
| 7 | public function transform($response) |
||
| 8 | { |
||
| 9 | $data = array(); |
||
| 10 | $response = $this->buildArray( $response ); |
||
|
|
|||
| 11 | |||
| 12 | if( !isset( $response['Items']['Item'] ) ) |
||
| 13 | { |
||
| 14 | return $data; |
||
| 15 | } |
||
| 16 | |||
| 17 | foreach( $response['Items']['Item'] as $item ) |
||
| 18 | { |
||
| 19 | if( !isset( $item['ItemAttributes']['Title'] ) ) |
||
| 20 | { |
||
| 21 | continue; |
||
| 22 | } |
||
| 23 | |||
| 24 | $row = array(); |
||
| 25 | |||
| 26 | $row['asin'] = $item['ASIN']; |
||
| 27 | $row['title'] = strip_tags( $item['ItemAttributes']['Title'] ); |
||
| 28 | |||
| 29 | if( isset( $item['LargeImage']['URL'] ) ) |
||
| 30 | { |
||
| 31 | $row['large_image'] = $item['LargeImage']['URL']; |
||
| 32 | } |
||
| 33 | |||
| 34 | if( isset( $item['MediumImage']['URL'] ) ) |
||
| 35 | { |
||
| 36 | $row['medium_image'] = $item['MediumImage']['URL']; |
||
| 37 | } |
||
| 38 | |||
| 39 | if( isset( $item['SmallImage']['URL'] ) ) |
||
| 40 | { |
||
| 41 | $row['small_image'] = $item['SmallImage']['URL']; |
||
| 42 | } |
||
| 43 | |||
| 44 | View Code Duplication | if( isset( $item['ItemAttributes']['ISBN'] ) ) |
|
| 45 | { |
||
| 46 | $row['isbn'] = $item['ItemAttributes']['ISBN']; |
||
| 47 | } |
||
| 48 | |||
| 49 | View Code Duplication | if( isset( $item['ItemAttributes']['Edition'] ) ) |
|
| 50 | { |
||
| 51 | $row['edition'] = $item['ItemAttributes']['Edition']; |
||
| 52 | } |
||
| 53 | |||
| 54 | if( isset( $item['ItemAttributes']['Author'] ) ) |
||
| 55 | { |
||
| 56 | $author = $item['ItemAttributes']['Author']; |
||
| 57 | if( ! is_array( $author ) ) |
||
| 58 | { |
||
| 59 | $author = array($author); |
||
| 60 | } |
||
| 61 | $row['author'] = $author; |
||
| 62 | } |
||
| 63 | |||
| 64 | $data[] = $row; |
||
| 65 | } |
||
| 66 | |||
| 67 | return $data; |
||
| 68 | } |
||
| 69 | |||
| 71 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.