FactFinderNgSuggestHandlerPlugin   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 2
b 0
f 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 3 1
A isApplicable() 0 3 2
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Client\FactFinderNg\Plugin;
9
10
use Spryker\Client\Kernel\AbstractPlugin;
11
use Spryker\Client\Search\Dependency\Plugin\QueryInterface;
12
13
/**
14
 * @method \SprykerEco\Client\FactFinderNg\FactFinderNgClientInterface getClient()
15
 */
16
class FactFinderNgSuggestHandlerPlugin extends AbstractPlugin implements FactFinderHandlerPluginInterface
17
{
18
    protected const PARAM_SUGGEST = 'suggest';
19
20
    /**
21
     * {@inheritDoc}
22
     * - The method uses suggest API request for handling search query.
23
     *
24
     * @api
25
     *
26
     * @param \Spryker\Client\Search\Dependency\Plugin\QueryInterface $searchQuery
27
     * @param array $resultFormatters
28
     * @param array $requestParameters
29
     *
30
     * @return mixed
31
     */
32
    public function handle(QueryInterface $searchQuery, array $resultFormatters = [], array $requestParameters = [])
33
    {
34
        return $this->getClient()->suggest($searchQuery, $resultFormatters, $requestParameters);
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     *
40
     * @api
41
     *
42
     * @param array $requestParameters
43
     *
44
     * @return bool
45
     */
46
    public function isApplicable(array $requestParameters): bool
47
    {
48
        return isset($requestParameters[static::PARAM_SUGGEST]) && $requestParameters[static::PARAM_SUGGEST];
49
    }
50
}
51