Completed
Push — master ( 511ebf...262cd3 )
by Mikołaj
21s queued 10s
created

ProductVariantRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findOneByOptionValue() 0 8 1
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\Repository;
14
15
use Doctrine\ORM\EntityRepository;
16
use Sylius\Component\Core\Model\ProductVariantInterface;
17
use Sylius\Component\Core\Repository\ProductVariantRepositoryInterface as BaseProductVariantRepositoryInterface;
18
use Sylius\Component\Product\Model\ProductOptionValueInterface;
19
20
final class ProductVariantRepository implements ProductVariantRepositoryInterface
21
{
22
    /** @var BaseProductVariantRepositoryInterface|EntityRepository */
23
    private $baseProductVariantRepository;
24
25
    public function __construct(BaseProductVariantRepositoryInterface $baseProductVariantRepository)
26
    {
27
        $this->baseProductVariantRepository = $baseProductVariantRepository;
28
    }
29
30
    public function findOneByOptionValue(ProductOptionValueInterface $productOptionValue): ?ProductVariantInterface
31
    {
32
        return $this->baseProductVariantRepository->createQueryBuilder('o')
0 ignored issues
show
Bug introduced by
The method createQueryBuilder() does not exist on Sylius\Component\Core\Re...iantRepositoryInterface. Did you maybe mean createQueryBuilderByProductId()? ( Ignorable by Annotation )

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

32
        return $this->baseProductVariantRepository->/** @scrutinizer ignore-call */ createQueryBuilder('o')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
            ->where(':optionValue MEMBER OF o.optionValues')
34
            ->setParameter('optionValue', $productOptionValue)
35
            ->getQuery()
36
            ->setMaxResults(1)
37
            ->getOneOrNullResult()
38
        ;
39
    }
40
}
41