Passed
Push — 5.0.0 ( 337324...37581b )
by Fèvre
05:07
created

Modal::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 8
dl 0
loc 12
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
declare(strict_types=1);
4
5
namespace Xetaravel\View\Components;
6
7
use Closure;
8
use Illuminate\Contracts\View\View;
9
use Illuminate\View\Component;
10
11
class Modal extends Component
12
{
13
    public function __construct(
14
        public ?string $id = '',
15
        public ?string $title = null,
16
        public ?string $subtitle = null,
17
        public ?string $boxClass = null,
18
        public ?bool $separator = false,
19
        public ?bool $persistent = false,
20
        public ?bool $withoutTrapFocus = false,
21
22
        // Slots
23
        public ?string $actions = null
24
    ) {
25
        //
26
    }
27
28
    /**
29
     * Get the view / contents that represent the component.
30
     */
31
    public function render(): View|Closure|string
32
    {
33
        return view('components.modal');
34
    }
35
}
36