Passed
Pull Request — 2.x (#1360)
by Harings
14:11
created

Map::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 9
dl 0
loc 17
rs 10

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 Map extends TwillFormComponent
6
{
7
    public $showMap;
8
    public $openMap;
9
    public $inModal;
10
    public $saveExtendedData;
11
    public $autoDetectLatLngValue;
12
13
    public function __construct(
14
        $name,
15
        $label,
16
        $renderForBlocks = false,
17
        $renderForModal = false,
18
        $showMap = true,
19
        $openMap = false,
20
        $fieldsInModal = false,
21
        $saveExtendedData = false,
22
        $autoDetectLatLngValue = false
23
    ) {
24
        parent::__construct($name, $label, $renderForBlocks, $renderForModal);
25
        $this->showMap = $showMap;
26
        $this->openMap = $openMap;
27
        $this->inModal = $fieldsInModal ?? false;
28
        $this->saveExtendedData = $saveExtendedData;
29
        $this->autoDetectLatLngValue = $autoDetectLatLngValue;
30
    }
31
32
    public function render()
33
    {
34
        return view('twill::partials.form._map');
35
    }
36
}
37