ShippingGatewayRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 12
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A findOneByShippingMethod() 0 7 1
A findOneByCode() 0 7 1
A createListQueryBuilder() 0 3 1
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\ShippingGatewayInterface;
14
use Doctrine\ORM\QueryBuilder;
15
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
16
use Sylius\Component\Shipping\Model\ShippingMethodInterface;
17
18
class ShippingGatewayRepository extends EntityRepository implements ShippingGatewayRepositoryInterface
19
{
20
    public function createListQueryBuilder(): QueryBuilder
21
    {
22
        return $this->createQueryBuilder('o');
23
    }
24
25
    public function findOneByCode(string $code): ?ShippingGatewayInterface
26
    {
27
        return $this->createQueryBuilder('o')
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createQuer...)->getOneOrNullResult() could return the type integer which is incompatible with the type-hinted return BitBag\SyliusShippingExp...ngGatewayInterface|null. Consider adding an additional type-check to rule them out.
Loading history...
28
            ->where('o.code = :code')
29
            ->setParameter('code', $code)
30
            ->getQuery()
31
            ->getOneOrNullResult()
32
        ;
33
    }
34
35
    public function findOneByShippingMethod(ShippingMethodInterface $shippingMethod): ?ShippingGatewayInterface
36
    {
37
        return $this->createQueryBuilder('o')
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createQuer...)->getOneOrNullResult() could return the type integer which is incompatible with the type-hinted return BitBag\SyliusShippingExp...ngGatewayInterface|null. Consider adding an additional type-check to rule them out.
Loading history...
38
            ->where(':shippingMethod MEMBER OF o.shippingMethods')
39
            ->setParameter('shippingMethod', $shippingMethod)
40
            ->getQuery()
41
            ->getOneOrNullResult()
42
        ;
43
    }
44
}
45