Completed
Pull Request — master (#24)
by Rafał
07:17
created

PaymentMethodProvider::getDefaultMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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\Entity\Repository\GatewayRepository;
11
use Newscoop\PaywallBundle\Adapter\AdapterFactory;
12
use Doctrine\Common\Persistence\ObjectRepository;
13
14
/**
15
 * Payment Method Provider class.
16
 */
17
class PaymentMethodProvider implements MethodProviderInterface
18
{
19
    /**
20
     * @var ObjectRepository
21
     */
22
    protected $gatewayRepository;
23
24
    /**
25
     * @param ObjectRepository $gatewayRepository
26
     */
27
    public function __construct(ObjectRepository $gatewayRepository)
28
    {
29
        $this->gatewayRepository = $gatewayRepository;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function getActiveMethod()
36
    {
37
        return $this->gatewayRepository
38
            ->findOneBy(array(
39
                'isActive' => true,
40
            ));
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getDefaultMethod()
47
    {
48
        return $this->gatewayRepository
49
            ->findOneBy(array(
50
                'value' => AdapterFactory::OFFLINE,
51
            ));
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getEnabledMethods()
58
    {
59
        return $this->gatewayRepository->findActive();
60
    }
61
}
62