| Conditions | 7 |
| Paths | 16 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 26 | public static function substr(string $what, int $offset, ?int $limit, string $errorMessage = ''): string |
||
| 27 | { |
||
| 28 | $length = strlen($what); |
||
| 29 | if (!is_null($limit) && ($limit > $length)) { // not over |
||
| 30 | $limit = null; |
||
| 31 | } |
||
| 32 | if (empty($limit)) { |
||
| 33 | $result = (!empty($offset)) ? substr($what, $offset) : $what ; |
||
| 34 | } else { |
||
| 35 | $result = (!empty($offset)) ? substr($what, $offset, $limit) : substr($what, 0, $limit); |
||
| 36 | } |
||
| 37 | if (false === $result) { |
||
| 38 | throw new UploadException($errorMessage); // failed substr |
||
| 39 | } |
||
| 40 | return $result; |
||
| 41 | } |
||
| 43 |