1 | <?php |
||
9 | class Inflector |
||
10 | { |
||
11 | protected $replacements; |
||
12 | |||
13 | /** |
||
14 | * construct. |
||
15 | * |
||
16 | * @param array $patterns |
||
17 | */ |
||
18 | 2 | public function __construct(array $patterns = array()) |
|
29 | |||
30 | /** |
||
31 | * return all replacements. |
||
32 | * |
||
33 | * @return array |
||
34 | */ |
||
35 | public function all() |
||
39 | |||
40 | /** |
||
41 | * translate given source string with setted replacement patterns. |
||
42 | * |
||
43 | * @param string $source |
||
44 | * |
||
45 | * @return string |
||
46 | */ |
||
47 | public function translate($source) |
||
51 | |||
52 | /** |
||
53 | * format camelCase. |
||
54 | * |
||
55 | * @param string $string |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | public function camelize($string) |
||
63 | |||
64 | /** |
||
65 | * format PascalCase. |
||
66 | * |
||
67 | * @param string $string |
||
68 | * |
||
69 | * @return string |
||
70 | * |
||
71 | * @see for inspiration https://github.com/symfony/dependency-injection/blob/master/Container.php#L342 |
||
72 | */ |
||
73 | public function pascalize($string) |
||
80 | |||
81 | /** |
||
82 | * format snake_case. |
||
83 | * |
||
84 | * @param string $string |
||
85 | * |
||
86 | * @return string |
||
87 | * |
||
88 | * @see for inspiration https://github.com/symfony/dependency-injection/blob/master/Container.php#L354 |
||
89 | */ |
||
90 | 2 | public function snakelize($string) |
|
98 | |||
99 | /** |
||
100 | * format spinal-case. |
||
101 | * |
||
102 | * @param string $string |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function spinalize($string) |
||
110 | |||
111 | /** |
||
112 | * format UPPER_CASE. |
||
113 | * |
||
114 | * @param string $string |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | public function uppercase($string) |
||
122 | |||
123 | /** |
||
124 | * Replace every "non-word" "non-ascii" characters in $string by $replacement. |
||
125 | * |
||
126 | * @param string $string |
||
127 | * @param string $replacement Default value is '-'. |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | public function slugify($string, $replacement = '-') |
||
151 | |||
152 | /** |
||
153 | * Normalize given data |
||
154 | * If an array is given, normalize keys, according to given method |
||
155 | * |
||
156 | * @param string|array &$data |
||
157 | * @param string $format |
||
158 | * |
||
159 | * @return string|array |
||
160 | * |
||
161 | * @see for inspiration https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Normalizer/CamelKeysNormalizer.php |
||
162 | */ |
||
163 | public function normalize(&$data, $format) |
||
191 | |||
192 | /** |
||
193 | * Replace '/' and '\' by current OS directory separator. |
||
194 | * |
||
195 | * This won't return the full path from the system root to a file, use realpath() or SplFileInfo::getRealPath() instead. |
||
196 | * |
||
197 | * @param string $string |
||
198 | * |
||
199 | * @return string |
||
200 | * |
||
201 | * @see http://php.net/php_uname |
||
202 | */ |
||
203 | public function directorize($string) |
||
207 | |||
208 | /** |
||
209 | * Force path to be UNIX style (i.e. '/path/to/something'). |
||
210 | * |
||
211 | * @param string $path |
||
212 | * |
||
213 | * @return string |
||
214 | */ |
||
215 | public function unixizePath($path) |
||
222 | } |
||
223 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.