| Total Complexity | 5 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | $phpSpellcheckLibraryNameSpellchecker = new class () implements SpellcheckerInterface { |
||
| 12 | public function check( |
||
| 13 | string $text, |
||
| 14 | array $languages, |
||
| 15 | array $context |
||
| 16 | ): iterable { |
||
| 17 | foreach (['php-spellchecker', 'php-spellcheckerer', 'php spellchecker'] as $misspelledCandidate) { |
||
| 18 | $matches = []; |
||
| 19 | |||
| 20 | if (preg_match('/\b'.$misspelledCandidate.'\b/i', $text, $matches, PREG_OFFSET_CAPTURE) !== false) { |
||
| 21 | foreach ($matches as $match) { |
||
| 22 | [$word, $offset] = $match; |
||
| 23 | [$line, $offsetFromLine] = LineAndOffset::findFromFirstCharacterOffset($text, $offset); |
||
| 24 | |||
| 25 | yield new Misspelling( |
||
| 26 | $word, |
||
| 27 | $offsetFromLine, |
||
| 28 | $line, |
||
| 29 | ['PHP Spellcheck'] |
||
| 30 | ); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getSupportedLanguages(): iterable |
||
| 39 | } |
||
| 40 | }; |
||
| 53 |