Passed
Pull Request — master (#148)
by Mateusz
12:54
created

OrderItemRepository::countByVariant()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
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
18
class OrderItemRepository implements OrderItemRepositoryInterface
19
{
20
    /** @var OrderItemRepositoryInterface */
21
    private $baseOrderItemRepository;
22
23
    public function __construct(EntityRepository $baseOrderItemRepository)
24
    {
25
        $this->baseOrderItemRepository = $baseOrderItemRepository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $baseOrderItemRepository of type Doctrine\ORM\EntityRepository is incompatible with the declared type BitBag\SyliusElasticsear...ItemRepositoryInterface of property $baseOrderItemRepository.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
26
    }
27
28
    public function countByVariant(ProductVariantInterface $variant): int
29
    {
30
        return (int) ($this->baseOrderItemRepository
31
            ->createQueryBuilder('orderItem')
0 ignored issues
show
Bug introduced by
The method createQueryBuilder() does not exist on BitBag\SyliusElasticsear...ItemRepositoryInterface. ( Ignorable by Annotation )

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

31
            ->/** @scrutinizer ignore-call */ createQueryBuilder('orderItem')

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...
32
            ->select('SUM(orderItem.quantity)')
33
            ->where('orderItem.variant = :variant')
34
            ->setParameter('variant', $variant)
35
            ->getQuery()->getSingleScalarResult());
36
    }
37
}
38