NamedProductsFinder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findByNamePart() 0 6 1
A __construct() 0 6 1
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusElasticsearchPlugin\Finder;
12
13
use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
14
use FOS\ElasticaBundle\Finder\FinderInterface;
15
16
final class NamedProductsFinder implements NamedProductsFinderInterface
17
{
18
    /** @var QueryBuilderInterface */
19
    private $productsByPartialNameQueryBuilder;
20
21
    /** @var FinderInterface */
22
    private $productsFinder;
23
24
    public function __construct(
25
        QueryBuilderInterface $productsByPartialNameQueryBuilder,
26
        FinderInterface $productsFinder
27
    ) {
28
        $this->productsByPartialNameQueryBuilder = $productsByPartialNameQueryBuilder;
29
        $this->productsFinder = $productsFinder;
30
    }
31
32
    public function findByNamePart(string $namePart): ?array
33
    {
34
        $data = ['name' => $namePart];
35
        $query = $this->productsByPartialNameQueryBuilder->buildQuery($data);
36
37
        return $this->productsFinder->find($query);
38
    }
39
}
40