| Total Complexity | 6 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class Clean |
||
| 10 | { |
||
| 11 | const INT = '0-9'; |
||
| 12 | const FLOAT = self::INT . '\,\.'; |
||
| 13 | const CHARS_RUS = 'а-яё'; |
||
| 14 | const CHARS_ENG = 'a-z'; |
||
| 15 | const SUPER = '\*\#\ \n\r'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Convert quotes to save format |
||
| 19 | * |
||
| 20 | * @param string $value |
||
| 21 | * @return string |
||
| 22 | */ |
||
| 23 | private static function fixQuotes(string $value): string |
||
| 24 | { |
||
| 25 | return htmlspecialchars(addslashes($value), ENT_QUOTES); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Compile regexp from string |
||
| 30 | * |
||
| 31 | * @param string $line |
||
| 32 | * @return string |
||
| 33 | */ |
||
| 34 | private static function compileRegexp(string $line): string |
||
| 35 | { |
||
| 36 | return '#[^' . $line . ']#iu'; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Cleanup the value |
||
| 41 | * |
||
| 42 | * @param string $value |
||
| 43 | * @param string $type |
||
| 44 | * @return mixed |
||
| 45 | */ |
||
| 46 | public static function run(string $value, string $type = null) |
||
| 69 | } |
||
| 70 | |||
| 71 | } |
||
| 72 |