Passed
Push — master ( b61938...703075 )
by
unknown
05:00
created

findAllWithNewOrPendingState()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusShippingExportPlugin\Repository;
12
13
use BitBag\SyliusShippingExportPlugin\Entity\ShippingExportInterface;
14
use Doctrine\ORM\QueryBuilder;
15
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
16
17
class ShippingExportRepository extends EntityRepository implements ShippingExportRepositoryInterface
18
{
19
    public const NEW_STATE_PARAMETER = 'newState';
20
21
    public const PENDING_STATE_PARAMETER = 'pendingState';
22
23
    public function createListQueryBuilder(): QueryBuilder
24
    {
25
        return $this->createQueryBuilder('o')
26
            ->leftJoin('o.shipment', 'shipment')
27
        ;
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public function findAllWithNewState(): array
34
    {
35
        trigger_deprecation('bitbag/shipping-export-plugin', '1.6', 'The "%s()" method is deprecated, use "ShippingExportRepository::findAllWithNewOrPendingState" instead.', __METHOD__);
36
37
        return $this->createQueryBuilder('o')
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createQuer...getQuery()->getResult() could return the type integer which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
38
            ->where('o.state = :newState')
39
            ->setParameter(self::NEW_STATE_PARAMETER, ShippingExportInterface::STATE_NEW)
40
            ->getQuery()
41
            ->getResult()
42
        ;
43
    }
44
45
    public function findAllWithNewOrPendingState(): array
46
    {
47
        return $this->createQueryBuilder('o')
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createQuer...getQuery()->getResult() could return the type integer which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
48
            ->where('o.state = :newState OR o.state = :pendingState')
49
            ->setParameter(self::NEW_STATE_PARAMETER, ShippingExportInterface::STATE_NEW)
50
            ->setParameter(self::PENDING_STATE_PARAMETER, ShippingExportInterface::STATE_PENDING)
51
            ->getQuery()
52
            ->getResult()
53
        ;
54
    }
55
}
56