PaymentMethodConfigResolver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\Resolver;
13
14
use BitBag\SyliusMolliePlugin\Entity\MollieGatewayConfigInterface;
15
use Sylius\Component\Resource\Repository\RepositoryInterface;
16
use Webmozart\Assert\Assert;
17
18
final class PaymentMethodConfigResolver implements PaymentMethodConfigResolverInterface
19
{
20
    /** @var RepositoryInterface */
21
    private $mollieMethodRepository;
22
23
    public function __construct(RepositoryInterface $mollieMethodRepository)
24
    {
25
        $this->mollieMethodRepository = $mollieMethodRepository;
26
    }
27
28
    public function getConfigFromMethodId(string $methodId): MollieGatewayConfigInterface
29
    {
30
        $paymentMethod = $this->mollieMethodRepository->findOneBy(['methodId' => $methodId]);
31
32
        Assert::notNull($paymentMethod, sprintf('Cannot find payment method config with method id %s', $methodId));
33
34
        return $paymentMethod;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $paymentMethod could return the type null which is incompatible with the type-hinted return BitBag\SyliusMolliePlugi...eGatewayConfigInterface. Consider adding an additional type-check to rule them out.
Loading history...
35
    }
36
}
37