Passed
Branch master (817642)
by Henri
02:11
created

RouteAttribute::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 2
b 0
f 1
nc 1
nop 8
dl 0
loc 11
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 HnrAzevedo\Router;
4
5
use Attribute;
6
7
#[Attribute]
8
class RouteAttribute
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,
0 ignored issues
show
Bug introduced by
The type HnrAzevedo\Router\Closure was not found. Did you mean Closure? If so, make sure to prefix the type with \.
Loading history...
16
        private ?string|Closure $before,
17
        private ?array $attributes,
18
        private ?array $middleware
19
    ) {
20
        echo 1;
21
22
    }
23
}
24