| Total Complexity | 9 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class Helper |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * round a number to nearest even number |
||
| 19 | * |
||
| 20 | * @param float $number |
||
| 21 | * @return int |
||
| 22 | */ |
||
| 23 | public static function roundToEven(float $number): int |
||
| 24 | { |
||
| 25 | return (($number = intval($number)) % 2 == 0) ? $number : $number + 1; |
||
| 26 | } |
||
| 27 | |||
| 28 | |||
| 29 | /** |
||
| 30 | * @param $dirname |
||
| 31 | */ |
||
| 32 | public static function makeDir($dirname): void |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param int $length |
||
| 41 | * @return bool|string |
||
| 42 | */ |
||
| 43 | public static function randomString($length = 10) |
||
| 44 | { |
||
| 45 | $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
||
| 46 | return substr(str_shuffle(str_repeat($chars, ceil($length / strlen($chars)))), 1, $length); |
||
|
|
|||
| 47 | |||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param $dir |
||
| 52 | * @return int|null |
||
| 53 | */ |
||
| 54 | public static function directorySize($dir) |
||
| 65 | } |
||
| 66 | } |