Conditions | 3 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | public function clean($username) |
||
23 | { |
||
24 | $username = strtolower($username); |
||
25 | // remove leading and trailing digits/-_ |
||
26 | $username = trim($username, " \t\n\r\0\x0B0123456789-_"); |
||
27 | |||
28 | // now only return a string only up to the first number/-_ char |
||
29 | $lenOfAlts = strcspn($username, '0123456789_-'); |
||
30 | if ($lenOfAlts > 1 && strlen($username) > $lenOfAlts) { |
||
31 | $username = substr($username, 0, $lenOfAlts); |
||
32 | } |
||
33 | |||
34 | return $username; |
||
35 | } |
||
37 |