1 | <?php |
||
10 | class CharacterFilter |
||
11 | { |
||
12 | protected $originalString; |
||
13 | protected $filteredString = ''; |
||
14 | |||
15 | /** |
||
16 | * CharacterFilter constructor. |
||
17 | * |
||
18 | * @param $string |
||
19 | */ |
||
20 | public function __construct($string) |
||
28 | |||
29 | /** |
||
30 | * Returns the filtered string |
||
31 | * @return string|void |
||
32 | */ |
||
33 | function __toString() |
||
37 | |||
38 | /** |
||
39 | * Filter out all special characters, like punctuation and characters with accents |
||
40 | * |
||
41 | * @param $string |
||
42 | * |
||
43 | * @return mixed|string |
||
44 | */ |
||
45 | private function filterSpecialCharacters($string) |
||
56 | |||
57 | /** |
||
58 | * Convert the string to UTF-8 encoding |
||
59 | * @param $string |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | private function convertToUTF8($string) |
||
74 | |||
75 | /** |
||
76 | * @return mixed|string |
||
77 | */ |
||
78 | public function getFilteredString() |
||
82 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.