Conditions | 6 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 7.8984 |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
11766 | 1 | public static function substr_in_byte(string $str, int $offset = 0, int $length = null) |
|
11767 | { |
||
11768 | // empty string |
||
11769 | 1 | if ($str === '' || $length === 0) { |
|
11770 | return ''; |
||
11771 | } |
||
11772 | |||
11773 | // whole string |
||
11774 | 1 | if (!$offset && $length === null) { |
|
11775 | return $str; |
||
11776 | } |
||
11777 | |||
11778 | 1 | if (self::$SUPPORT['mbstring_func_overload'] === true) { |
|
11779 | // "mb_" is available if overload is used, so use it ... |
||
11780 | return \mb_substr($str, $offset, $length, 'CP850'); // 8-BIT |
||
11781 | } |
||
11782 | |||
11783 | 1 | return \substr($str, $offset, $length ?? 2147483647); |
|
11784 | } |
||
13689 |