Test Setup Failed
Push — main ( abdcb9...2e5f68 )
by Slawomir
04:37
created

FindUserPostHeadersQueryResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
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 9
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 App\Modules\Security\Api\Query\Response;
4
5
use Symfony\Component\Uid\Ulid;
6
7
class FindUserPostHeadersQueryResponse
8
{
9
    /**
10
     * @param Ulid $id
11
     * @param string $title
12
     * @param string $summary
13
     * @param array $tags
14
     * @param Ulid $createdById
15
     * @param string $createdByName
16
     * @param \DateTime $createdAt
17
     * @param int $version
18
     */
19
    public function __construct(private Ulid      $id,
20
                                private string    $title,
21
                                private string    $summary,
22
                                private array     $tags,
23
                                private Ulid      $createdById,
24
                                private string    $createdByName,
25
                                private \DateTime $createdAt,
26
                                private int       $version)
27
    {
28
    }
29
30
    /**
31
     * @return Ulid
32
     */
33
    public function getId(): Ulid
34
    {
35
        return $this->id;
36
    }
37
38
39
    /**
40
     * @return string
41
     */
42
    public function getTitle(): string
43
    {
44
        return $this->title;
45
    }
46
47
    /**
48
     * @return string
49
     */
50
    public function getSummary(): string
51
    {
52
        return $this->summary;
53
    }
54
55
    /**
56
     * @return array
57
     */
58
    public function getTags(): array
59
    {
60
        return $this->tags;
61
    }
62
63
    /**
64
     * @return \DateTime
65
     */
66
    public function getCreatedAt(): \DateTime
67
    {
68
        return $this->createdAt;
69
    }
70
71
    /**
72
     * @return int
73
     */
74
    public function getVersion(): int
75
    {
76
        return $this->version;
77
    }
78
79
    /**
80
     * @return Ulid
81
     */
82
    public function getCreatedById(): Ulid
83
    {
84
        return $this->createdById;
85
    }
86
87
    /**
88
     * @return string
89
     */
90
    public function getCreatedByName(): string
91
    {
92
        return $this->createdByName;
93
    }
94
95
96
}