CurrencyConverterHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A serializeToJson() 0 8 2
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\Serializer;
9
10
use JMS\Serializer\JsonSerializationVisitor;
11
use Newscoop\PaywallBundle\Currency\Context\CurrencyContextInterface;
12
use Newscoop\PaywallBundle\Entity\PriceableInterface;
13
use Sylius\Component\Currency\Converter\CurrencyConverterInterface;
14
15
/**
16
 * Currency converter handler. Handles currency conversion.
17
 */
18
class CurrencyConverterHandler
19
{
20
    private $converter;
21
    private $context;
22
23
    /**
24
     * Construct.
25
     *
26
     * @param CurrencyConverterInterface $converter
27
     * @param CurrencyContextInterface   $context
28
     */
29
    public function __construct(CurrencyConverterInterface $converter, CurrencyContextInterface $context)
30
    {
31
        $this->converter = $converter;
32
        $this->context = $context;
33
    }
34
35
    public function serializeToJson(JsonSerializationVisitor $visitor, PriceableInterface $subscription)
0 ignored issues
show
Unused Code introduced by
The parameter $visitor is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        if (!$subscription) {
38
            return;
39
        }
40
41
        return $this->converter->convert($subscription->getPrice(), $this->context->getCurrency());
42
    }
43
}
44