| Total Complexity | 1 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | trait Strings |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Split a string by string. |
||
| 9 | * |
||
| 10 | * Based on explode, see http://php.net/manual/en/function.explode.php. |
||
| 11 | * |
||
| 12 | * __::split('a-b-c', '-', 2); |
||
| 13 | * >> ['a', 'b-c'] |
||
| 14 | * |
||
| 15 | * @param string $input The string to split. |
||
| 16 | * @param string $delimiter The boundary string. |
||
| 17 | * @param int $limit (optional) If limit is set and positive, the returned array |
||
| 18 | * will contain a maximum of limit elements with the last element containing the |
||
| 19 | * rest of string. |
||
| 20 | * If the limit parameter is negative, all components except the last -limit are returned. |
||
| 21 | * If the limit parameter is zero, then this is treated as 1. |
||
| 22 | * |
||
| 23 | * @return string |
||
| 24 | */ |
||
| 25 | 17 | public static function split($input, $delimiter, $limit = PHP_INT_MAX) |
|
| 28 | } |
||
| 29 | } |