Passed
Push — master ( 2fd05c...9d8025 )
by Bruno
02:00
created

CardRenderer::canRender()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
4
 * See COPYING.txt for license details.
5
 */
6
7
namespace Moip\Magento2\Block\Customer;
8
9
use Magento\Vault\Api\Data\PaymentTokenInterface;
10
use Magento\Vault\Block\AbstractCardRenderer;
11
use Moip\Magento2\Model\Ui\ConfigProviderBase;
12
13
class CardRenderer extends AbstractCardRenderer
14
{
15
    /**
16
     * Can render specified token.
17
     *
18
     * @param PaymentTokenInterface $token
19
     *
20
     * @return bool
21
     */
22
    public function canRender(PaymentTokenInterface $token): bool
23
    {
24
        return $token->getPaymentMethodCode() === ConfigProviderBase::METHOD_CODE_CC;
25
    }
26
27
    /**
28
     * @return string
29
     */
30
    public function getNumberLast4Digits(): string
31
    {
32
        return $this->getTokenDetails()['cc_last4'];
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getExpDate(): string
39
    {
40
        return $this->getTokenDetails()['cc_exp_month'].'/'.$this->getTokenDetails()['cc_exp_year'];
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getIconUrl(): string
47
    {
48
        return $this->getIconForType($this->getTokenDetails()['cc_type'])['url'];
49
    }
50
51
    /**
52
     * @return int
53
     */
54
    public function getIconHeight(): int
55
    {
56
        return $this->getIconForType($this->getTokenDetails()['cc_type'])['height'];
57
    }
58
59
    /**
60
     * @return int
61
     */
62
    public function getIconWidth(): int
63
    {
64
        return $this->getIconForType($this->getTokenDetails()['cc_type'])['width'];
65
    }
66
}
67