Conditions | 1 |
Paths | 1 |
Total Lines | 62 |
Code Lines | 34 |
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 |
||
62 | public function wrapData() |
||
63 | { |
||
64 | return [ |
||
65 | [ // simple string |
||
66 | ['1234567890'], |
||
67 | 5, |
||
68 | [ |
||
69 | '12345', |
||
70 | '67890', |
||
71 | ], |
||
72 | ], |
||
73 | [ // boundary test |
||
74 | ['123456'], |
||
75 | 5, |
||
76 | ['12345', '6'], |
||
77 | ], |
||
78 | [ // array of strings |
||
79 | [ |
||
80 | '1234567890123456789012345678901234567890', |
||
81 | '123456789012345678901234567890', |
||
82 | ], |
||
83 | 20, |
||
84 | [ |
||
85 | '12345678901234567890', |
||
86 | '12345678901234567890', |
||
87 | '12345678901234567890', |
||
88 | '1234567890', |
||
89 | ], |
||
90 | ], |
||
91 | [ // support multi-byte characters |
||
92 | ['😀😃😄😁😆😅😂🤣☺😊😇🙂🙃😉😌😍😘😗😙😚😋😜😝😛🤑🤗🤓😎🤡🤠😏😒😞😔😟😕🙁😣😖😫😩😤😠😡😶😐😑😯😦😧😮😲😵😳😱😨😰😢😥'], |
||
93 | 20, |
||
94 | [ |
||
95 | '😀😃😄😁😆😅😂🤣☺😊😇🙂🙃😉😌😍😘😗😙😚', |
||
96 | '😋😜😝😛🤑🤗🤓😎🤡🤠😏😒😞😔😟😕🙁😣😖😫', |
||
97 | '😩😤😠😡😶😐😑😯😦😧😮😲😵😳😱😨😰😢😥', |
||
98 | ], |
||
99 | ], |
||
100 | [ // strip tags and wrap on non stripped version |
||
101 | [ |
||
102 | "\e[13m1234567890\e[42m1234567890\e[15m12345678901234567890\e[42m", |
||
103 | "\e[17m12345678901234567890\e[42m1234567890", |
||
104 | ], |
||
105 | 20, |
||
106 | [ |
||
107 | "\e[13m1234567890\e[42m1234567890\e[15m", |
||
108 | "12345678901234567890\e[42m", |
||
109 | "\e[17m12345678901234567890\e[42m", |
||
110 | '1234567890', |
||
111 | ], |
||
112 | ], |
||
113 | [ // ignore tags |
||
114 | ['<info>info</info>infowarning<warning>warning</warning>warning'], |
||
115 | 10, |
||
116 | [ |
||
117 | '<info>info', |
||
118 | '</info>inf', |
||
119 | 'owarning<w', |
||
120 | 'arning>war', |
||
121 | 'ning</warn', |
||
122 | 'ing>warnin', |
||
123 | 'g' |
||
124 | ], |
||
203 |