Route::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 8
dl 0
loc 10
rs 10
c 0
b 0
f 0

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 HnrAzevedo\Router;
4
5
use Attribute;
6
7
#[Attribute]
8
class Route
9
{
10
    public function __construct(
11
        private string $uri,
12
        private array $methods,
13
        private string $name,
14
        private ?array $where,
15
        private ?string|?\Closure $after,
16
        private ?string|?\Closure $before,
17
        private ?array $attributes,
18
        private ?array $middleware
19
    ) {}
20
}
21