Conditions | 10 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
56 | protected function convertAuteur($data, $indice) |
||
57 | { |
||
58 | // author ['name'=>'Bob','@type'=>'Person'] |
||
59 | if (0 === $indice |
||
60 | && isset($data['author']) |
||
61 | && isset($data['author']['name']) |
||
62 | && (!isset($data['author']['@type']) |
||
63 | || 'Person' === $data['author']['@type']) |
||
64 | ) { |
||
65 | return html_entity_decode($data['author']['name']); |
||
66 | } |
||
67 | |||
68 | // author [ 0 => ['name'=>'Bob'], 1=> ...] |
||
69 | if (isset($data['author']) && isset($data['author'][$indice]) |
||
70 | && (!isset($data['author'][$indice]['@type']) |
||
71 | || 'Person' === $data['author'][$indice]['@type']) |
||
72 | ) { |
||
73 | return html_entity_decode($data['author'][$indice]['name']); |
||
74 | } |
||
75 | |||
76 | return null; |
||
77 | } |
||
103 |