| Conditions | 3 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 5 | public function toTexts(array $context = []): iterable |
|
| 34 | 5 | { |
|
| 35 | 5 | $context['filePath'] = \Safe\realpath($this->filePath); |
|
| 36 | 1 | $encoding = $this->encoding; |
|
| 37 | |||
| 38 | if ($encoding === null) { |
||
| 39 | 4 | $encoding = mb_detect_encoding($this->getFileContent(), null, true); |
|
| 40 | |||
| 41 | if ($encoding === false) { |
||
| 42 | 5 | throw new RuntimeException( |
|
| 43 | \Safe\sprintf( |
||
| 44 | 5 | 'Coulnd\'t detect enconding of string:' . PHP_EOL . '%s', |
|
| 45 | $this->getFileContent() |
||
| 46 | ) |
||
| 47 | 5 | ); |
|
| 48 | 5 | } |
|
| 49 | 4 | } |
|
| 50 | 4 | ||
| 51 | |||
| 52 | return [ |
||
| 53 | new Text( |
||
| 54 | $this->getFileContent(), |
||
| 55 | $encoding, |
||
| 56 | $context |
||
| 57 | ), |
||
| 61 |