Conditions | 2 |
Paths | 2 |
Total Lines | 51 |
Code Lines | 40 |
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 |
||
47 | protected function clean(?string $str = null): ?string |
||
48 | { |
||
49 | if ($str === null) { |
||
50 | return null; |
||
51 | } |
||
52 | $str = $this->stripEmailAdress($str); |
||
53 | |||
54 | $str = str_replace( |
||
55 | [ |
||
56 | '|', |
||
57 | "\n", |
||
58 | "\t", |
||
59 | "\r", |
||
60 | ''', |
||
61 | ''', |
||
62 | ''', |
||
63 | ''', |
||
64 | "\n", |
||
65 | " ", |
||
66 | "é", |
||
67 | '©', |
||
68 | '{{', |
||
69 | '}}', |
||
70 | '[[', |
||
71 | ']]', |
||
72 | ], |
||
73 | [ |
||
74 | '/', |
||
75 | ' ', |
||
76 | ' ', |
||
77 | '', |
||
78 | "’", |
||
79 | "'", |
||
80 | "'", |
||
81 | "'", |
||
82 | '', |
||
83 | ' ', |
||
84 | "é", |
||
85 | '', |
||
86 | '', |
||
87 | '', |
||
88 | '', |
||
89 | '', |
||
90 | ], |
||
91 | $str |
||
92 | ); |
||
93 | |||
94 | $str = html_entity_decode($str); |
||
95 | $str = strip_tags($str); |
||
96 | |||
97 | return trim($str); |
||
98 | } |
||
176 |