ProductColumn   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 19
c 1
b 0
f 0
dl 0
loc 66
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A _toHtml() 0 7 2
A setInputName() 0 3 1
A setInputId() 0 3 1
A getSourceOptions() 0 9 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
declare(strict_types=1);
10
11
namespace Getnet\SubSellerMagento\Block\Adminhtml\System\Form\Field\Column;
12
13
use Magento\Framework\View\Element\Html\Select;
14
15
/**
16
 * Class ProductColumn - Create Field to Product Column.
17
 */
18
class ProductColumn extends Select
19
{
20
    public const CREDITO_1X = 'CREDITO A VISTA';
21
22
    public const CREDITO_PARCELADO_3X = 'PARCELADO LOJISTA 3X';
23
24
    public const CREDITO_PARCELADO_6X = 'PARCELADO LOJISTA 6X';
25
26
    public const CREDITO_PARCELADO_9X = 'PARCELADO LOJISTA 9X';
27
28
    public const CREDITO_PARCELADO_12X = 'PARCELADO LOJISTA 12X';
29
30
    public const BOLETO = 'BOLETO';
31
32
    /**
33
     * Set "name" for <select> element.
34
     *
35
     * @param string $value
36
     *
37
     * @return void
38
     */
39
    public function setInputName($value)
40
    {
41
        return $this->setName($value);
0 ignored issues
show
Bug introduced by
The method setName() does not exist on Getnet\SubSellerMagento\...ld\Column\ProductColumn. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        return $this->/** @scrutinizer ignore-call */ setName($value);
Loading history...
Bug Best Practice introduced by
The expression return $this->setName($value) also could return the type Getnet\SubSellerMagento\...uctColumn|array|boolean which is incompatible with the documented return type void.
Loading history...
42
    }
43
44
    /**
45
     * Set "id" for <select> element.
46
     *
47
     * @param string $value
48
     *
49
     * @return void
50
     */
51
    public function setInputId($value)
52
    {
53
        return $this->setId($value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->setId($value) returns the type Getnet\SubSellerMagento\...ld\Column\ProductColumn which is incompatible with the documented return type void.
Loading history...
54
    }
55
56
    /**
57
     * Render block HTML.
58
     *
59
     * @return string
60
     */
61
    public function _toHtml(): string
62
    {
63
        if (!$this->getOptions()) {
64
            $this->setOptions($this->getSourceOptions());
65
        }
66
67
        return parent::_toHtml();
68
    }
69
70
    /**
71
     * Get Options.
72
     *
73
     * @return array
74
     */
75
    public function getSourceOptions(): array
76
    {
77
        return [
78
            ['value' => self::CREDITO_1X, 'label' => 'Pagamento em crédito à vista'],
79
            ['value' => self::CREDITO_PARCELADO_3X, 'label' => 'Pagamento em crédito até 3 parcelas'],
80
            ['value' => self::CREDITO_PARCELADO_6X, 'label' => 'Pagamento em crédito até 6 parcelas'],
81
            ['value' => self::CREDITO_PARCELADO_9X, 'label' => 'Pagamento em crédito até 9 parcelas'],
82
            ['value' => self::CREDITO_PARCELADO_12X, 'label' => 'Pagamento em crédito até 12 parcelas'],
83
            ['value' => self::BOLETO, 'label' => 'Pagamento por Boleto'],
84
        ];
85
    }
86
}
87