Issues (3641)

ProductReview/Search/ProductReviewSearchReader.php (1 issue)

1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace Spryker\Client\ProductReview\Search;
9
10
use Generated\Shared\Transfer\ProductReviewSearchRequestTransfer;
11
use Spryker\Client\ProductReview\Dependency\Client\ProductReviewToSearchInterface;
12
use Spryker\Client\Search\Dependency\Plugin\QueryInterface;
13
14
class ProductReviewSearchReader implements ProductReviewSearchReaderInterface
15
{
16
    /**
17
     * @var \Spryker\Client\Search\Dependency\Plugin\QueryInterface
18
     */
19
    protected $searchQueryPlugin;
20
21
    /**
22
     * @var \Spryker\Client\ProductReview\Dependency\Client\ProductReviewToSearchInterface
23
     */
24
    protected $searchClient;
25
26
    /**
27
     * @var array<\Spryker\Client\Search\Dependency\Plugin\ResultFormatterPluginInterface>
28
     */
29
    protected $searchResultFormatterPlugins;
30
31
    /**
32
     * @param \Spryker\Client\Search\Dependency\Plugin\QueryInterface $productReviewsQueryPlugin
33
     * @param \Spryker\Client\ProductReview\Dependency\Client\ProductReviewToSearchInterface $searchClient
34
     * @param array<\Spryker\Client\Search\Dependency\Plugin\ResultFormatterPluginInterface> $searchResultFormatterPlugins
35
     */
36
    public function __construct(
37
        QueryInterface $productReviewsQueryPlugin,
38
        ProductReviewToSearchInterface $searchClient,
39
        array $searchResultFormatterPlugins
40
    ) {
41
        $this->searchQueryPlugin = $productReviewsQueryPlugin;
42
        $this->searchClient = $searchClient;
43
        $this->searchResultFormatterPlugins = $searchResultFormatterPlugins;
44
    }
45
46
    /**
47
     * @param \Generated\Shared\Transfer\ProductReviewSearchRequestTransfer $productReviewSearchRequestTransfer
48
     *
49
     * @return array
50
     */
51
    public function findProductReviews(ProductReviewSearchRequestTransfer $productReviewSearchRequestTransfer): array
52
    {
53
        return $this->searchClient->search(
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->searchClie...er->getRequestParams()) could return the type Elastica\ResultSet which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
54
            $this->searchQueryPlugin,
55
            $this->searchResultFormatterPlugins,
56
            $productReviewSearchRequestTransfer->getRequestParams(),
57
        );
58
    }
59
60
    /**
61
     * @return \Elastica\ResultSet|mixed|array
62
     */
63
    public function searchProductReviews()
64
    {
65
        return $this->searchClient->search(
66
            $this->searchQueryPlugin,
67
            $this->searchResultFormatterPlugins,
68
        );
69
    }
70
}
71