CurrencyProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAvailableCurrencies() 0 6 1
A getDefaultCurrency() 0 8 1
A getEnabledCurrencies() 0 5 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 Sylius\Component\Currency\Provider\CurrencyProvider as BaseProvider;
11
use Newscoop\PaywallBundle\Entity\Repository\CurrencyRepository;
12
13
/**
14
 * Currency Provider class.
15
 */
16
class CurrencyProvider extends BaseProvider
17
{
18
    /**
19
     * @param CurrencyRepository $currencyRepository
20
     */
21
    public function __construct(CurrencyRepository $currencyRepository)
22
    {
23
        parent::__construct($currencyRepository);
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getAvailableCurrencies()
30
    {
31
        return $this->currencyRepository
0 ignored issues
show
Bug introduced by
The method findAllAvailable() does not exist on Sylius\Component\Resourc...ory\RepositoryInterface. Did you maybe mean findAll()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
32
            ->findAllAvailable()
33
            ->getResult();
34
    }
35
36
    /**
37
     * Gets the default currency.
38
     *
39
     * @return null|Sylius\Component\Currency\Model\CurrencyInterface
40
     */
41
    public function getDefaultCurrency()
42
    {
43
        return $this->currencyRepository
44
            ->findOneBy(array(
45
                'isActive' => true,
46
                'default' => true,
47
            ));
48
    }
49
50
    /**
51
     * Gets the default currency.
52
     *
53
     * @return array
54
     */
55
    public function getEnabledCurrencies()
56
    {
57
        return $this->currencyRepository
58
            ->findBy(array('isActive' => true));
59
    }
60
}
61