CcType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllowedTypes() 0 3 1
A toOptionArray() 0 12 3
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\Model\Adminhtml\Source;
10
11
use Magento\Payment\Model\Source\Cctype as MagentoCcType;
12
13
/**
14
 * Class CcType - Defines credit card types.
15
 */
16
class CcType extends MagentoCcType
17
{
18
    /**
19
     * Get Allwed Types.
20
     *
21
     * @return array
22
     */
23
    public function getAllowedTypes(): array
24
    {
25
        return ['HC', 'ELO', 'AE', 'VI', 'MC'];
26
    }
27
28
    /**
29
     * Returns Options.
30
     *
31
     * @return array
32
     */
33
    public function toOptionArray(): array
34
    {
35
        $allowed = $this->getAllowedTypes();
36
        $options = [];
37
38
        foreach ($this->_paymentConfig->getCcTypes() as $code => $name) {
39
            if (in_array($code, $allowed)) {
40
                $options[] = ['value' => $code, 'label' => $name];
41
            }
42
        }
43
44
        return $options;
45
    }
46
}
47