Passed
Pull Request — develop (#83)
by
unknown
19:12 queued 04:07
created

Event::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 13
dl 0
loc 18
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 InShore\Bookwhen\Domain;
6
7
use InShore\Bookwhen\Domain\Location;
8
9
final class Event
10
{
11
    /**
12
     *
13
     */
14
    public readonly int $attendeeAvailable;
15
16
    /**
17
     *
18
     */
19
    public readonly bool $finished;
20
21
    /**
22
     *
23
     */
24
    public readonly bool $soldOut;
25
26
    /**
27
     *
28
     *
29
     */
30
    public function __construct(
31
        public readonly bool $allDay,
32
        public 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 array $tickets,
42
        public readonly string $title,
43
        public readonly bool $waitingList
44
    ) {
45
        $this->attendeeAvailable = $this->attendeeLimit - $this->attendeeCount;
0 ignored issues
show
Bug introduced by
The property attendeeAvailable is declared read-only in InShore\Bookwhen\Domain\Event.
Loading history...
46
        $this->finished = false; // @todo
0 ignored issues
show
Bug introduced by
The property finished is declared read-only in InShore\Bookwhen\Domain\Event.
Loading history...
47
        $this->soldOut = ($this->attendeeCount === $this->attendeeLimit);
0 ignored issues
show
Bug introduced by
The property soldOut is declared read-only in InShore\Bookwhen\Domain\Event.
Loading history...
48
    }
49
50
51
52
}
53