PaymentMethodRepository   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A findOneByGatewayFactoryNameAndChannel() 0 13 1
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
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusQuadPayPlugin\Repository;
14
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
final class PaymentMethodRepository extends BasePaymentMethodRepository implements PaymentMethodRepositoryInterface
20
{
21
    public function findOneByGatewayFactoryNameAndChannel(string $gatewayFactoryName, ChannelInterface $channel): ?PaymentMethodInterface
22
    {
23
        return $this->createQueryBuilder('o')
24
            ->innerJoin('o.gatewayConfig', 'gatewayConfig')
25
            ->where('gatewayConfig.factoryName = :gatewayFactoryName')
26
            ->andWhere(':channel MEMBER OF o.channels')
27
            ->andWhere('o.enabled = true')
28
            ->addOrderBy('o.position')
29
            ->setParameter('gatewayFactoryName', $gatewayFactoryName)
30
            ->setParameter('channel', $channel)
31
            ->setMaxResults(1)
32
            ->getQuery()
33
            ->getOneOrNullResult()
34
        ;
35
    }
36
}
37