Passed
Pull Request — master (#2)
by Igor
08:27
created

createLagersystemListQueryBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 21
rs 9.7998
cc 1
nc 1
nop 0
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 ShipmentRepositoryTrait
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('shipment')
25
            ->join('shipment.order', 'o')
26
27
            ->andWhere('o.checkoutState in (:checkoutStates)')
28
            ->setParameter('checkoutStates', [
29
                OrderCheckoutStates::STATE_COMPLETED,
30
            ])
31
32
            ->andWhere('o.shippingState NOT in (:shippingState)')
33
            ->setParameter('shippingState', [
34
                OrderShippingStates::STATE_SHIPPED,
35
            ])
36
37
            ->andWhere('o.paymentState in (:paymentState)')
38
            ->setParameter('paymentState', [
39
                OrderPaymentStates::STATE_AUTHORIZED,
40
                OrderPaymentStates::STATE_PARTIALLY_AUTHORIZED,
41
                OrderPaymentStates::STATE_PAID,
42
                OrderPaymentStates::STATE_PARTIALLY_PAID,
43
            ])
44
            ;
45
    }
46
}
47