findOneByChannelAndGatewayFactoryName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 12
rs 9.9332
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * You can find more information about us on https://bitbag.io and write us
7
 * an email on [email protected].
8
 */
9
10
declare(strict_types=1);
11
12
namespace BitBag\SyliusMolliePlugin\Repository;
13
14
use BitBag\SyliusMolliePlugin\Factory\MollieGatewayFactory;
15
use Sylius\Bundle\CoreBundle\Doctrine\ORM\PaymentMethodRepository as BasePaymentMethodRepository;
16
use Sylius\Component\Core\Model\ChannelInterface;
17
use Sylius\Component\Core\Model\PaymentMethodInterface;
18
19
class PaymentMethodRepository extends BasePaymentMethodRepository implements PaymentMethodRepositoryInterface
20
{
21
    public function findAllByFactoryNameAndCode(string $code): array
22
    {
23
        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...
24
            ->innerJoin('o.gatewayConfig', 'gatewayConfig')
25
            ->where('gatewayConfig.factoryName = :factoryName')
26
            ->andWhere('o.code != :code')
27
            ->setParameter('factoryName', MollieGatewayFactory::FACTORY_NAME)
28
            ->setParameter('code', $code)
29
            ->getQuery()
30
            ->getResult()
31
        ;
32
    }
33
34
    public function findOneByChannelAndGatewayFactoryName(ChannelInterface $channel, $factoryName): ?PaymentMethodInterface
35
    {
36
        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 Sylius\Component\Core\Mo...entMethodInterface|null. Consider adding an additional type-check to rule them out.
Loading history...
37
            ->innerJoin('o.gatewayConfig', 'gatewayConfig')
38
            ->andWhere('o.enabled = true')
39
            ->andWhere(':channel MEMBER OF o.channels')
40
            ->andWhere('gatewayConfig.factoryName = :factoryName')
41
            ->setParameter('channel', $channel)
42
            ->setParameter('factoryName', $factoryName)
43
            ->addOrderBy('o.position')
44
            ->getQuery()
45
            ->getOneOrNullResult()
46
            ;
47
    }
48
}
49