Total Complexity | 8 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
11 | class Strings |
||
12 | { |
||
13 | 17 | public static function mb_chr(int $number): string |
|
14 | { |
||
15 | 17 | $part = intval(round($number / 256)); |
|
16 | 17 | return |
|
17 | 17 | ((0 < $part) ? static::mb_chr($part) : '') |
|
18 | 17 | . chr($number % 256); |
|
19 | } |
||
20 | |||
21 | 16 | public static function mb_ord(string $str): int |
|
22 | { |
||
23 | 16 | $len = strlen($str); |
|
24 | 16 | $char = (1 < $len) ? substr($str, $len - 1) : $str; |
|
25 | 16 | $next = (1 < $len) ? substr($str, 0, $len - 1) : '' ; |
|
26 | 16 | return |
|
27 | 16 | ( (!empty($next)) ? ( static::mb_ord($next) * 256 ) : 0 ) |
|
28 | 16 | + ord($char) ; |
|
29 | } |
||
30 | |||
31 | 17 | public static function filler(int $input, int $length): string |
|
32 | { |
||
33 | 17 | return str_pad( |
|
34 | 17 | substr(static::mb_chr($input), 0, $length), |
|
35 | 17 | $length, |
|
36 | 17 | chr(0), |
|
37 | 17 | STR_PAD_LEFT); |
|
38 | } |
||
39 | |||
40 | 16 | public static function cutter(string $data, int $start, int $length): int |
|
43 | } |
||
44 | } |
||
45 |