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

Checkbox::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
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 11
dl 0
loc 22
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
        $form = [],
20
        $note = false,
21
        $default = false,
22
        $fieldsInModal = false,
23
        $disabled = false,
24
        $border = false,
25
        $confirmMessageText = false,
26
        $confirmTitleText = false,
27
        $requireConfirmation = false
28
    ) {
29
        parent::__construct($name, $label, $form);
30
        $this->note = $note;
31
        $this->default = $default;
32
        $this->fieldsInModal = $fieldsInModal;
33
        $this->disabled = $disabled;
34
        $this->border = $border;
35
        $this->confirmMessageText = $confirmMessageText;
36
        $this->confirmTitleText = $confirmTitleText;
37
        $this->requireConfirmation = $requireConfirmation;
38
    }
39
40
    public function render()
41
    {
42
        return view('twill::partials.form._checkbox');
43
    }
44
}
45