| Conditions | 13 |
| Paths | 4096 |
| Total Lines | 27 |
| Code Lines | 25 |
| 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 |
||
| 72 | function createArticleFromArray($data) |
||
| 73 | { |
||
| 74 | $title = isset($data['title']) ? $data['title'] : ''; |
||
| 75 | $body = isset($data['body']) ? $data['body'] : ''; |
||
| 76 | $source = isset($data['source']) ? $data['source'] : ''; |
||
| 77 | $uniqueId = isset($data['uniqueId']) ? $data['uniqueId'] : ''; |
||
| 78 | $typeId = isset($data['typeId']) ? $data['typeId'] : null; |
||
| 79 | $categoryId = isset($data['categoryId']) ? $data['categoryId'] : null; |
||
| 80 | $reporter = isset($data['reporter']) ? $data['reporter'] : ''; |
||
|
|
|||
| 81 | $lead = isset($data['lead']) ? $data['lead'] : ''; |
||
| 82 | $reporter = isset($data['reporter']) ? $data['reporter'] : ''; |
||
| 83 | $tags = isset($data['tags']) ? $data['tags'] : ''; |
||
| 84 | $publishedAt = isset($data['publishedAt']) ? $data['publishedAt'] : null; |
||
| 85 | $identifier = isset($data['identifier']) ? $data['identifier'] : null; |
||
| 86 | return new Article( |
||
| 87 | $title, |
||
| 88 | $body, |
||
| 89 | $source, |
||
| 90 | $uniqueId, |
||
| 91 | $typeId, |
||
| 92 | $categoryId, |
||
| 93 | $reporter, |
||
| 94 | $lead, |
||
| 95 | $reporter, |
||
| 96 | $tags, |
||
| 97 | $publishedAt, |
||
| 98 | $identifier |
||
| 99 | ); |
||
| 101 |