Completed
Push — master ( f5f0a4...73fb80 )
by Łukasz
10:35
created

PaymentDescriptionProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPaymentDescription() 0 14 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\PayumBundle\Provider;
13
14
use Sylius\Component\Core\Model\OrderInterface;
15
use Sylius\Component\Core\Model\PaymentInterface;
16
use Symfony\Component\Translation\TranslatorInterface;
17
18
/**
19
 * @author Stefan Doorn <[email protected]>
20
 */
21
final class PaymentDescriptionProvider implements PaymentDescriptionProviderInterface
22
{
23
    /**
24
     * @var TranslatorInterface
25
     */
26
    private $translator;
27
28
    /**
29
     * @param TranslatorInterface $translator
30
     */
31
    public function __construct(TranslatorInterface $translator)
32
    {
33
        $this->translator = $translator;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getPaymentDescription(PaymentInterface $payment)
40
    {
41
        /** @var OrderInterface $order */
42
        $order = $payment->getOrder();
43
44
        return $this->translator->transChoice(
45
            'sylius.payum_action.payment.description',
46
            $order->getItems()->count(),
47
            [
48
                '%items%' => $order->getItems()->count(),
49
                '%total%' => round($order->getTotal() / 100, 2),
50
            ]
51
        );
52
    }
53
}
54