Completed
Pull Request — master (#143)
by Beñat
03:38
created

CreateTaskCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 21
nc 1
nop 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 Kreta\TaskManager\Application\Project\Task;
6
7
class CreateTaskCommand
8
{
9
    private $title;
10
    private $description;
11
    private $creatorMemberId;
12
    private $creatorUserId;
13
    private $assigneeMemberId;
14
    private $assigneeUserId;
15
    private $priority;
16
    private $projectId;
17
    private $parentId;
18
    private $taskId;
19
20
    public function __construct(
21
        string $title,
22
        string $description,
23
        string $creatorMemberId,
24
        string $creatorUserId,
25
        string $assigneeMemberId,
26
        string $assigneeUserId,
27
        string $priority,
28
        string $projectId,
29
        string $parentId = null,
30
        string $taskId = null
31
    ) {
32
        $this->title = $title;
33
        $this->description = $description;
34
        $this->creatorMemberId = $creatorMemberId;
35
        $this->creatorUserId = $creatorUserId;
36
        $this->assigneeMemberId = $assigneeMemberId;
37
        $this->assigneeUserId = $assigneeUserId;
38
        $this->priority = $priority;
39
        $this->projectId = $projectId;
40
        $this->parentId = $parentId;
41
        $this->taskId = $taskId;
42
    }
43
44
    public function title() : string
45
    {
46
        return $this->title;
47
    }
48
49
    public function description() : string
50
    {
51
        return $this->description;
52
    }
53
54
    public function creatorMemberId() : string
55
    {
56
        return $this->creatorMemberId;
57
    }
58
59
    public function creatorUserId() : string
60
    {
61
        return $this->creatorUserId;
62
    }
63
64
    public function assigneeMemberId() : string
65
    {
66
        return $this->assigneeMemberId;
67
    }
68
69
    public function assigneeUserId() : string
70
    {
71
        return $this->assigneeUserId;
72
    }
73
74
    public function priority() : string
75
    {
76
        return $this->priority;
77
    }
78
79
    public function projectId() : string
80
    {
81
        return $this->projectId;
82
    }
83
84
    public function parentId()
85
    {
86
        return $this->parentId;
87
    }
88
89
    public function taskId()
90
    {
91
        return $this->taskId;
92
    }
93
}
94