Passed
Pull Request — 2.x (#1360)
by Harings
09:37
created

Checkbox::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 12
dl 0
loc 23
rs 9.9666

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace A17\Twill\View\Components;
4
5
class Checkbox extends TwillFormComponent
6
{
7
    public $note;
8
    public $default;
9
    public $fieldsInModal;
10
    public $disabled;
11
    public $border;
12
    public $confirmMessageText;
13
    public $confirmTitleText;
14
    public $requireConfirmation;
15
16
    public function __construct(
17
        $name,
18
        $label,
19
        $renderForBlocks = false,
20
        $renderForModal = false,
21
        $note = false,
22
        $default = false,
23
        $fieldsInModal = false,
24
        $disabled = false,
25
        $border = false,
26
        $confirmMessageText = false,
27
        $confirmTitleText = false,
28
        $requireConfirmation = false
29
    ) {
30
        parent::__construct($name, $label, $renderForBlocks, $renderForModal);
31
        $this->note = $note;
32
        $this->default = $default;
33
        $this->fieldsInModal = $fieldsInModal;
34
        $this->disabled = $disabled;
35
        $this->border = $border;
36
        $this->confirmMessageText = $confirmMessageText;
37
        $this->confirmTitleText = $confirmTitleText;
38
        $this->requireConfirmation = $requireConfirmation;
39
    }
40
41
    public function render()
42
    {
43
        return view('twill::partials.form._checkbox');
44
    }
45
}
46