Conditions | 4 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7028 | 2 | public static function str_offset_get(string $str, int $index, string $encoding = 'UTF-8'): string |
|
7029 | { |
||
7030 | // init |
||
7031 | 2 | $length = (int) self::strlen($str); |
|
7032 | |||
7033 | if ( |
||
7034 | 2 | ($index >= 0 && $length <= $index) |
|
7035 | || |
||
7036 | 2 | $length < \abs($index) |
|
7037 | ) { |
||
7038 | 1 | throw new \OutOfBoundsException('No character exists at the index'); |
|
7039 | } |
||
7040 | |||
7041 | 1 | return self::char_at($str, $index, $encoding); |
|
7042 | } |
||
13722 |