Conditions | 1 |
Paths | 1 |
Total Lines | 81 |
Code Lines | 43 |
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 |
||
16 | public static function create() : array |
||
17 | { |
||
18 | /** @var Closure */ |
||
19 | $stringClosure = function (string $data) : string { |
||
20 | return $data; |
||
21 | }; |
||
22 | |||
23 | return [ |
||
24 | /* Name */ |
||
25 | new ArrayMapper('detail', [ |
||
26 | new ArrayMapper('0', [ |
||
27 | new ArrayMapper('pullRequests', [ |
||
28 | new ArrayMapper('0', [ |
||
29 | new FieldMapper('name', $stringClosure), |
||
30 | ]), |
||
31 | ]), |
||
32 | ]), |
||
33 | ], 'pull_request_name'), |
||
34 | |||
35 | /* Url */ |
||
36 | new ArrayMapper('detail', [ |
||
37 | new ArrayMapper('0', [ |
||
38 | new ArrayMapper('pullRequests', [ |
||
39 | new ArrayMapper('0', [ |
||
40 | new FieldMapper('url', $stringClosure), |
||
41 | ]), |
||
42 | ]), |
||
43 | ]), |
||
44 | ], 'pull_request_url'), |
||
45 | |||
46 | /* Status */ |
||
47 | new ArrayMapper('detail', [ |
||
48 | new ArrayMapper('0', [ |
||
49 | new ArrayMapper('pullRequests', [ |
||
50 | new ArrayMapper('0', [ |
||
51 | new FieldMapper('status', $stringClosure), |
||
52 | ]), |
||
53 | ]), |
||
54 | ]), |
||
55 | ], 'pull_request_status'), |
||
56 | |||
57 | /* Last update */ |
||
58 | new ArrayMapper('detail', [ |
||
59 | new ArrayMapper('0', [ |
||
60 | new ArrayMapper('pullRequests', [ |
||
61 | new ArrayMapper('0', [ |
||
62 | new FieldMapper('lastUpdate', $stringClosure), |
||
63 | ]), |
||
64 | ]), |
||
65 | ]), |
||
66 | ], 'pull_request_last_update'), |
||
67 | |||
68 | /* Branch */ |
||
69 | new ArrayMapper('detail', [ |
||
70 | new ArrayMapper('0', [ |
||
71 | new ArrayMapper('pullRequests', [ |
||
72 | new ArrayMapper('0', [ |
||
73 | new ArrayMapper('source', [ |
||
74 | new FieldMapper('branch', $stringClosure), |
||
75 | ]), |
||
76 | ]), |
||
77 | ]), |
||
78 | ]), |
||
79 | ], 'pull_request_branch'), |
||
80 | |||
81 | /* Repository */ |
||
82 | new ArrayMapper('detail', [ |
||
83 | new ArrayMapper('0', [ |
||
84 | new ArrayMapper('pullRequests', [ |
||
85 | new ArrayMapper('0', [ |
||
86 | new ArrayMapper('source', [ |
||
87 | new ArrayMapper('repository', [ |
||
88 | new FieldMapper('name', $stringClosure), |
||
89 | ]), |
||
90 | ]), |
||
91 | ]), |
||
92 | ]), |
||
93 | ]), |
||
94 | ], 'repository'), |
||
95 | ]; |
||
96 | } |
||
97 | } |
||
98 |