| Conditions | 5 |
| Paths | 1 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | 2 | public function __construct(string $data, string $delimiter = '') |
|
| 28 | { |
||
| 29 | 2 | $this->callable = |
|
| 30 | /** |
||
| 31 | * @return Generator<int, string> |
||
| 32 | */ |
||
| 33 | 2 | static function (string $input, string $delimiter): Generator { |
|
| 34 | 2 | $offset = 0; |
|
| 35 | |||
| 36 | while ( |
||
| 37 | 2 | mb_strlen($input) > $offset |
|
| 38 | 2 | && false !== $nextOffset = '' !== $delimiter ? mb_strpos($input, $delimiter, $offset) : 1 + $offset |
|
| 39 | ) { |
||
| 40 | 2 | yield mb_substr($input, $offset, $nextOffset - $offset); |
|
| 41 | |||
| 42 | 2 | $offset = $nextOffset + mb_strlen($delimiter); |
|
| 43 | } |
||
| 44 | |||
| 45 | 2 | if ('' !== $delimiter) { |
|
| 46 | 1 | yield mb_substr($input, $offset); |
|
| 47 | } |
||
| 48 | 2 | }; |
|
| 49 | 2 | $this->data = $data; |
|
| 50 | 2 | $this->delimiter = $delimiter; |
|
| 51 | 2 | } |
|
| 61 |