CardRenderer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 62
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getIconWidth() 0 3 1
A canRender() 0 3 1
A getExpDate() 0 3 1
A getIconUrl() 0 3 1
A getIconHeight() 0 3 1
A getNumberLast4Digits() 0 3 1
1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
9
namespace Getnet\PaymentMagento\Block\Customer;
10
11
use Getnet\PaymentMagento\Model\Ui\ConfigProviderBase;
12
use Magento\Vault\Api\Data\PaymentTokenInterface;
13
use Magento\Vault\Block\AbstractCardRenderer;
14
15
class CardRenderer extends AbstractCardRenderer
16
{
17
    /**
18
     * Can render specified token.
19
     *
20
     * @param PaymentTokenInterface $token
21
     *
22
     * @return bool
23
     */
24
    public function canRender(PaymentTokenInterface $token): bool
25
    {
26
        return $token->getPaymentMethodCode() === ConfigProviderBase::METHOD_CODE_CC;
27
    }
28
29
    /**
30
     * Get Last Numbers.
31
     *
32
     * @return string
33
     */
34
    public function getNumberLast4Digits(): string
35
    {
36
        return $this->getTokenDetails()['cc_last4'];
37
    }
38
39
    /**
40
     * Get Expiration Date.
41
     *
42
     * @return string
43
     */
44
    public function getExpDate(): string
45
    {
46
        return $this->getTokenDetails()['cc_exp_month'].'/'.$this->getTokenDetails()['cc_exp_year'];
47
    }
48
49
    /**
50
     * Get Icon Url.
51
     *
52
     * @return string
53
     */
54
    public function getIconUrl(): string
55
    {
56
        return $this->getIconForType($this->getTokenDetails()['cc_type'])['url'];
57
    }
58
59
    /**
60
     * Get Icon Height.
61
     *
62
     * @return int
63
     */
64
    public function getIconHeight(): int
65
    {
66
        return $this->getIconForType($this->getTokenDetails()['cc_type'])['height'];
67
    }
68
69
    /**
70
     *  Get Icon Width.
71
     *
72
     * @return int
73
     */
74
    public function getIconWidth(): int
75
    {
76
        return $this->getIconForType($this->getTokenDetails()['cc_type'])['width'];
77
    }
78
}
79