Passed
Push — master ( 11d34c...33485b )
by US
13:49 queued 06:53
created

OrderItemRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
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\OrderInterface;
17
use Sylius\Component\Core\Model\ProductVariantInterface;
18
19
class OrderItemRepository implements OrderItemRepositoryInterface
20
{
21
    /** @var OrderItemRepositoryInterface */
22
    private $baseOrderItemRepository;
23
24
    public function __construct(EntityRepository $baseOrderItemRepository)
25
    {
26
        $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...
27
    }
28
29
    public function countByVariant(ProductVariantInterface $variant, array $orderStates = []): int
30
    {
31
        if (empty($orderStates)) {
32
            $orderStates = [OrderInterface::STATE_CANCELLED, OrderInterface::STATE_CART];
33
        }
34
35
        return (int) ($this->baseOrderItemRepository
36
            ->createQueryBuilder('oi')
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

36
            ->/** @scrutinizer ignore-call */ createQueryBuilder('oi')

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...
37
            ->select('SUM(oi.quantity)')
38
            ->join('oi.order', 'o')
39
            ->where('oi.variant = :variant')
40
            ->andWhere('o.state NOT IN (:states)')
41
            ->setParameter('variant', $variant)
42
            ->setParameter('states', $orderStates)
43
            ->getQuery()
44
            ->getSingleScalarResult());
45
    }
46
}
47