PaymentMethodsProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSupportedMethods() 0 10 2
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