SoliDry /
api-generator
| 1 | <?php |
||
| 2 | namespace SoliDry\Extension; |
||
| 3 | |||
| 4 | use SoliDry\Types\ConfigInterface; |
||
| 5 | use SoliDry\Types\PhpInterface; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Class SpellCheckTrait |
||
| 9 | * |
||
| 10 | * @package SoliDry\Extension |
||
| 11 | * |
||
| 12 | * @property ApiController entity |
||
| 13 | */ |
||
| 14 | trait SpellCheckTrait |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Field spell checker |
||
| 18 | * |
||
| 19 | * @param array $jsonProps |
||
| 20 | * |
||
| 21 | * @return array |
||
| 22 | */ |
||
| 23 | protected function spellCheck(array $jsonProps) : array |
||
| 24 | { |
||
| 25 | if (extension_loaded(PhpInterface::PHP_EXTENSION_PSPELL) === false) { |
||
| 26 | return [ConfigInterface::SPELL_CHECK => 'php-pspell library has not been installed on Your system.']; |
||
| 27 | } |
||
| 28 | |||
| 29 | $arr = []; |
||
| 30 | $spellCheck = new SpellCheck($this->entity); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 31 | $field = $spellCheck->getField(); |
||
| 32 | if ($spellCheck->isEnabled() === true) { |
||
| 33 | $arr = $spellCheck->check($jsonProps[$field]); |
||
| 34 | } |
||
| 35 | |||
| 36 | return [ConfigInterface::SPELL_CHECK => [$field => $arr]]; |
||
| 37 | } |
||
| 38 | } |