Completed
Push — master ( 663845...79fb76 )
by Igor
18s queued 13s
created

createLagersystemListQueryBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 13
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 19
rs 9.8333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusLagersystemPlugin\Repository;
6
7
use Doctrine\ORM\QueryBuilder;
8
use Sylius\Component\Core\OrderCheckoutStates;
9
use Sylius\Component\Core\OrderPaymentStates;
10
use Sylius\Component\Core\OrderShippingStates;
11
12
trait OrderRepositoryTrait
13
{
14
    /**
15
     * @param string $alias
16
     * @param string $indexBy The index for the from.
17
     *
18
     * @return QueryBuilder
19
     */
20
    abstract public function createQueryBuilder($alias, $indexBy = null);
21
22
    public function createLagersystemListQueryBuilder(): QueryBuilder
23
    {
24
        return $this->createQueryBuilder('o')
25
            ->andWhere('o.checkoutState in (:checkoutStates)')
26
            ->setParameter('checkoutStates', [
27
                OrderCheckoutStates::STATE_COMPLETED,
28
            ])
29
30
            ->andWhere('o.shippingState NOT in (:shippingState)')
31
            ->setParameter('shippingState', [
32
                OrderShippingStates::STATE_SHIPPED,
33
            ])
34
35
            ->andWhere('o.paymentState in (:paymentState)')
36
            ->setParameter('paymentState', [
37
                OrderPaymentStates::STATE_AUTHORIZED,
38
                OrderPaymentStates::STATE_PARTIALLY_AUTHORIZED,
39
                OrderPaymentStates::STATE_PAID,
40
                OrderPaymentStates::STATE_PARTIALLY_PAID,
41
            ])
42
            ;
43
    }
44
}
45