Completed
Pull Request — master (#61)
by Mikołaj
06:33 queued 02:13
created

getUniqueAttributeValues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusElasticsearchPlugin\EntityRepository;
14
15
use Sylius\Bundle\ProductBundle\Doctrine\ORM\ProductAttributeValueRepositoryInterface as BaseAttributeValueRepositoryInterface;
0 ignored issues
show
Bug introduced by
The type Sylius\Bundle\ProductBun...alueRepositoryInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Sylius\Component\Attribute\Model\AttributeInterface;
17
18
final class ProductAttributeValueRepository implements ProductAttributeValueRepositoryInterface
19
{
20
    /** @var BaseAttributeValueRepositoryInterface */
21
    private $baseAttributeValueRepository;
22
23
    public function __construct(BaseAttributeValueRepositoryInterface $baseAttributeValueRepository)
24
    {
25
        $this->baseAttributeValueRepository = $baseAttributeValueRepository;
26
    }
27
28
    public function getUniqueAttributeValues(AttributeInterface $productAttribute): array
29
    {
30
        $queryBuilder = $this->repository->createQueryBuilder('o');
0 ignored issues
show
Bug Best Practice introduced by
The property repository does not exist on BitBag\SyliusElasticsear...ttributeValueRepository. Did you maybe forget to declare it?
Loading history...
31
32
        return $queryBuilder
33
            ->where('o.attribute = :attribute')
34
            ->groupBy('o.' . $productAttribute->getStorageType())
35
            ->setParameter(':attribute', $productAttribute)
36
            ->getQuery()
37
            ->getResult()
38
        ;
39
    }
40
}
41