PaymentMethodProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getActiveMethod() 0 7 1
A getDefaultMethod() 0 7 1
A getEnabledMethods() 0 4 1
1
<?php
2
3
/**
4
 * @author Rafał Muszyński <[email protected]>
5
 * @copyright 2015 Sourcefabric z.ú.
6
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
7
 */
8
namespace Newscoop\PaywallBundle\Provider;
9
10
use Newscoop\PaywallBundle\Adapter\AdapterFactory;
11
use Doctrine\Common\Persistence\ObjectRepository;
12
13
/**
14
 * Payment Method Provider class.
15
 */
16
class PaymentMethodProvider implements MethodProviderInterface
17
{
18
    /**
19
     * @var ObjectRepository
20
     */
21
    protected $gatewayRepository;
22
23
    /**
24
     * @param ObjectRepository $gatewayRepository
25
     */
26
    public function __construct(ObjectRepository $gatewayRepository)
27
    {
28
        $this->gatewayRepository = $gatewayRepository;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function getActiveMethod()
35
    {
36
        return $this->gatewayRepository
37
            ->findOneBy(array(
38
                'isActive' => true,
39
            ));
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function getDefaultMethod()
46
    {
47
        return $this->gatewayRepository
48
            ->findOneBy(array(
49
                'value' => AdapterFactory::OFFLINE,
50
            ));
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function getEnabledMethods()
57
    {
58
        return $this->gatewayRepository->findActive();
59
    }
60
}
61