Passed
Push — master ( d6e9da...34ad5f )
by Mikołaj
04:01
created

ProductVariantRepository::findOneByOptionValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 0
loc 14
rs 9.4285
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 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
    /**
23
     * @var BaseProductVariantRepositoryInterface|EntityRepository
24
     */
25
    private $baseProductVariantRepository;
26
27
    /**
28
     * @param BaseProductVariantRepositoryInterface|EntityRepository $baseProductVariantRepository
29
     */
30
    public function __construct(BaseProductVariantRepositoryInterface $baseProductVariantRepository)
31
    {
32
        $this->baseProductVariantRepository = $baseProductVariantRepository;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function findOneByOptionValue(ProductOptionValueInterface $productOptionValue): ProductVariantInterface
39
    {
40
        $productVariant = $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

40
        $productVariant = $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...
41
            ->where(':optionValue MEMBER OF o.optionValues')
42
            ->setParameter('optionValue', $productOptionValue)
43
            ->getQuery()
44
            ->getOneOrNullResult()
45
        ;
46
47
        if (null === $productVariant) {
48
            throw new \UnexpectedValueException('Product variant was not found!');
49
        }
50
51
        return $productVariant;
52
    }
53
}
54