PaymentDescriptionProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPaymentDescription() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PH\Bundle\PayumBundle\Provider;
6
7
use PH\Component\Core\Model\PaymentInterface;
8
use PH\Component\Core\Model\SubscriptionInterface;
9
use Symfony\Component\Translation\TranslatorInterface;
10
11
final class PaymentDescriptionProvider implements PaymentDescriptionProviderInterface
12
{
13
    /**
14
     * @var TranslatorInterface
15
     */
16
    private $translator;
17
18
    /**
19
     * @param TranslatorInterface $translator
20
     */
21
    public function __construct(TranslatorInterface $translator)
22
    {
23
        $this->translator = $translator;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getPaymentDescription(PaymentInterface $payment): string
30
    {
31
        /** @var SubscriptionInterface $subscription */
32
        $subscription = $payment->getSubscription();
33
34
        return $this->translator->trans('ph.payum_action.payment.description', [
35
            '%total%' => round($subscription->getTotal() / 100, 2),
36
            '%currency%' => $subscription->getCurrencyCode(),
37
        ]);
38
    }
39
}
40