Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 50 |
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 |
||
39 | public function cleanString($value): string |
||
40 | { |
||
41 | $value = (string) $value; |
||
42 | $search = [ |
||
43 | "\u{0001}", // start of heading |
||
44 | "\u{0002}", // start of text |
||
45 | "\u{0003}", // end of text |
||
46 | "\u{0004}", // end of transmission |
||
47 | "\u{0005}", // enquiry |
||
48 | "\u{0006}", // ACK |
||
49 | "\u{0007}", // BEL |
||
50 | "\u{0008}", // backspace |
||
51 | "\u{000E}", // shift out |
||
52 | "\u{000F}", // shift in |
||
53 | "\u{0010}", // data link escape |
||
54 | "\u{0011}", // DC1 |
||
55 | "\u{0012}", // DC2 |
||
56 | "\u{0013}", // DC3 |
||
57 | "\u{0014}", // DC4 |
||
58 | "\u{0015}", // NAK |
||
59 | "\u{0016}", // SYN |
||
60 | "\u{0017}", // ETB |
||
61 | "\u{0018}", // CAN |
||
62 | "\u{0019}", // EM |
||
63 | "\u{001A}", // SUB |
||
64 | "\u{001B}", // escape |
||
65 | "\u{001C}", // file separator |
||
66 | "\u{001D}", // group separator |
||
67 | "\u{001E}", // record separator |
||
68 | "\u{001F}", // unit separator |
||
69 | "\u{007F}", // DEL |
||
70 | "\u{00A0}", // non-breaking space |
||
71 | "\u{1680}", // ogham space mark |
||
72 | "\u{180E}", // mongolian vowel separator |
||
73 | "\u{2000}", // en quad |
||
74 | "\u{2001}", // em quad |
||
75 | "\u{2002}", // en space |
||
76 | "\u{2003}", // em space |
||
77 | "\u{2004}", // three-per-em space |
||
78 | "\u{2005}", // four-per-em space |
||
79 | "\u{2006}", // six-per-em space |
||
80 | "\u{2007}", // figure space |
||
81 | "\u{2008}", // punctuation space |
||
82 | "\u{2009}", // thin space |
||
83 | "\u{200A}", // hair space |
||
84 | "\u{200B}", // zero width space |
||
85 | "\u{202F}", // narrow no-break space |
||
86 | "\u{3000}", // ideographic space |
||
87 | "\u{FEFF}", // zero width no -break space |
||
88 | "\t", // TAB |
||
89 | "\r", // CARRIAGE RETURN! |
||
90 | ]; |
||
91 | |||
92 | return trim(str_replace($search, "\x20", $value)); |
||
93 | } |
||
108 |