Issues (150)

src/Extension/SpellCheckTrait.php (1 issue)

Labels
Severity
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
$this->entity of type SoliDry\Extension\ApiController is incompatible with the type string expected by parameter $entity of SoliDry\Extension\SpellCheck::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
        $spellCheck = new SpellCheck(/** @scrutinizer ignore-type */ $this->entity);
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
}