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

ShipmentRepositoryTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 15
c 0
b 0
f 0
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createLagersystemListQueryBuilder() 0 21 1
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