| Total Complexity | 7 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | class Helper |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * round a number to nearest even number |
||
| 22 | * |
||
| 23 | * @param float $number |
||
| 24 | * @return int |
||
| 25 | */ |
||
| 26 | public static function roundToEven(float $number): int |
||
| 27 | { |
||
| 28 | return (($number = intval($number)) % 2 == 0) ? $number : $number + 1; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param int $length |
||
| 33 | * @return bool|string |
||
| 34 | */ |
||
| 35 | public static function randomString($length = 10) |
||
| 36 | { |
||
| 37 | $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
||
| 38 | return substr(str_shuffle(str_repeat($chars, ceil($length / strlen($chars)))), 1, $length); |
||
|
|
|||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param $word |
||
| 43 | * @return bool|string |
||
| 44 | */ |
||
| 45 | public static function appendSlash(string $word) |
||
| 46 | { |
||
| 47 | if ($word) { |
||
| 48 | return rtrim($word, '/') . '/'; |
||
| 49 | } |
||
| 50 | return $word; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param $url |
||
| 55 | * @return bool |
||
| 56 | */ |
||
| 57 | public static function isURL(string $url) |
||
| 64 | } |
||
| 65 | } |