FieldSizeColumn::_toHtml()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
rs 10
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 FieldSizeColumn - Create Field to Size Column.
17
 */
18
class FieldSizeColumn extends Select
19
{
20
    public const A_HUNDRED_PERCENT = 'a-hundred-percent';
21
22
    public const SIXTY_PERCENT = 'sixty-percent';
23
24
    public const FIFTY_PERCENT = 'fifty-percent';
25
26
    public const THIRTY_THREE_PERCENT = 'thirty-three-percent';
27
28
    public const TWENTY_PERCENT = 'twenty-percent';
29
30
    /**
31
     * Set "name" for <select> element.
32
     *
33
     * @param string $value
34
     *
35
     * @return void
36
     */
37
    public function setInputName($value)
38
    {
39
        return $this->setName($value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->setName($value) also could return the type O2TI\AdvancedFieldsCheck...izeColumn|array|boolean which is incompatible with the documented return type void.
Loading history...
Bug introduced by
The method setName() does not exist on O2TI\AdvancedFieldsCheck...\Column\FieldSizeColumn. 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...
40
    }
41
42
    /**
43
     * Set "id" for <select> element.
44
     *
45
     * @param string $value
46
     *
47
     * @return void
48
     */
49
    public function setInputId($value)
50
    {
51
        return $this->setId($value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->setId($value) returns the type O2TI\AdvancedFieldsCheck...\Column\FieldSizeColumn which is incompatible with the documented return type void.
Loading history...
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
     * Get Options.
70
     *
71
     * @return array
72
     */
73
    public function getSourceOptions(): array
74
    {
75
        return [
76
            ['value' => self::A_HUNDRED_PERCENT, 'label' => '100%'],
77
            ['value' => self::SIXTY_PERCENT, 'label' => '60%'],
78
            ['value' => self::FIFTY_PERCENT, 'label' => '50%'],
79
            ['value' => self::THIRTY_THREE_PERCENT, 'label' => '33%'],
80
            ['value' => self::TWENTY_PERCENT, 'label' => '20%'],
81
        ];
82
    }
83
}
84