FieldIsBreakLineColumn   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setInputName() 0 3 1
A _toHtml() 0 7 2
A getSourceOptions() 0 5 1
A setInputId() 0 3 1
1
<?php
2
/**
3
 * Copyright © O2TI. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See COPYING.txt for license details.
7
 */
8
9
declare(strict_types=1);
10
11
namespace O2TI\AdvancedFieldsCheckout\Block\Adminhtml\Form\Field\Column;
12
13
use Magento\Framework\View\Element\Html\Select;
14
15
/**
16
 * Class FieldIsBreakLineColumn - Create Field to BreakLine.
17
 */
18
class FieldIsBreakLineColumn extends Select
19
{
20
    /**
21
     * Value which equal Enable for Enabledisable dropdown.
22
     */
23
    public const ENABLE_VALUE = 1;
24
25
    /**
26
     * Value which equal Disable for Enabledisable dropdown.
27
     */
28
    public const DISABLE_VALUE = 0;
29
30
    /**
31
     * Set "name" for <select> element.
32
     *
33
     * @param string $value
34
     *
35
     * @return $this
36
     */
37
    public function setInputName($value)
38
    {
39
        return $this->setName($value);
0 ignored issues
show
Bug introduced by
The method setName() does not exist on O2TI\AdvancedFieldsCheck...\FieldIsBreakLineColumn. 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

39
        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 array|boolean which is incompatible with the documented return type O2TI\AdvancedFieldsCheck...\FieldIsBreakLineColumn.
Loading history...
40
    }
41
42
    /**
43
     * Set "id" for <select> element.
44
     *
45
     * @param string $value
46
     *
47
     * @return $this
48
     */
49
    public function setInputId($value)
50
    {
51
        return $this->setId($value);
52
    }
53
54
    /**
55
     * Render block HTML.
56
     *
57
     * @return string
58
     */
59
    public function _toHtml(): string
60
    {
61
        if (!$this->getOptions()) {
62
            $this->setOptions($this->getSourceOptions());
63
        }
64
65
        return parent::_toHtml();
66
    }
67
68
    /**
69
     * Render Options.
70
     *
71
     * @return array
72
     */
73
    private function getSourceOptions(): array
74
    {
75
        return [
76
            ['value' => self::ENABLE_VALUE, 'label' => __('Enable')],
77
            ['value' => self::DISABLE_VALUE, 'label' => __('Disable')],
78
        ];
79
    }
80
}
81