CurrencyOrderVisitor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A visitOrder() 0 6 1
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 * 
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 * 
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\OrderBundle\Visitor;
14
15
use WellCommerce\Bundle\AppBundle\Service\Currency\Helper\CurrencyHelperInterface;
16
use WellCommerce\Bundle\OrderBundle\Entity\Order;
17
18
/**
19
 * Class CurrencyOrderVisitor
20
 *
21
 * @author  Adam Piotrowski <[email protected]>
22
 */
23
final class CurrencyOrderVisitor implements OrderVisitorInterface
24
{
25
    /**
26
     * @var CurrencyHelperInterface
27
     */
28
    private $currencyHelper;
29
    
30
    public function __construct(CurrencyHelperInterface $currencyHelper)
31
    {
32
        $this->currencyHelper = $currencyHelper;
33
    }
34
    
35
    public function visitOrder(Order $order)
36
    {
37
        $currency     = $order->getCurrency();
38
        $currencyRate = $this->currencyHelper->getCurrencyRate($currency);
39
        $order->setCurrencyRate($currencyRate);
40
    }
41
}
42