Conditions | 1 |
Paths | 1 |
Total Lines | 18 |
Code Lines | 3 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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 |
||
30 | 3 | public function __construct( |
|
31 | public readonly bool $allDay, |
||
32 | public readonly array $attachments, |
||
33 | public readonly int $attendeeCount, |
||
34 | public readonly int $attendeeLimit, |
||
35 | public readonly string $details, |
||
36 | public readonly string $endAt, |
||
37 | public readonly string $id, |
||
38 | public readonly Location $location, |
||
39 | public readonly int $maxTicketsPerBooking, |
||
40 | public readonly string $startAt, |
||
41 | public readonly array $tickets, |
||
42 | public readonly string $title, |
||
43 | public readonly bool $waitingList |
||
44 | ) { |
||
45 | 3 | $this->attendeeAvailable = $this->attendeeLimit - $this->attendeeCount; |
|
46 | 3 | $this->finished = false; // @todo |
|
47 | 3 | $this->soldOut = ($this->attendeeCount === $this->attendeeLimit); |
|
48 | } |
||
50 |