PaymentMethodsProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PH\Bundle\CoreBundle\Provider;
6
7
use PH\Component\Core\Model\SubscriptionInterface;
8
use PH\Component\Core\Repository\PaymentMethodRepositoryInterface;
9
10
final class PaymentMethodsProvider implements PaymentMethodsProviderInterface
11
{
12
    /**
13
     * @var PaymentMethodRepositoryInterface
14
     */
15
    private $paymentMethodRepository;
16
17
    /**
18
     * PaymentMethodsProvider constructor.
19
     *
20
     * @param PaymentMethodRepositoryInterface $paymentMethodRepository
21
     */
22
    public function __construct(PaymentMethodRepositoryInterface $paymentMethodRepository)
23
    {
24
        $this->paymentMethodRepository = $paymentMethodRepository;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function getSupportedMethods(string $type): array
31
    {
32
        $supportsRecurring = false;
33
34
        if (SubscriptionInterface::TYPE_RECURRING === $type) {
35
            $supportsRecurring = true;
36
        }
37
38
        return $this->paymentMethodRepository->findBySupportsRecurring($supportsRecurring);
39
    }
40
}
41