Completed
Pull Request — master (#180)
by Gorka
05:29
created

CreateTaskCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 17
nc 1
nop 8

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
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Kreta\TaskManager\Application\Command\Project\Task;
16
17
class CreateTaskCommand
18
{
19
    private $title;
20
    private $description;
21
    private $creatorId;
22
    private $assigneeId;
23
    private $priority;
24
    private $projectId;
25
    private $parentId;
26
    private $taskId;
27
28
    public function __construct(
29
        string $title,
30
        string $description,
31
        string $creatorId,
32
        string $assigneeId,
33
        string $priority,
34
        string $projectId,
35
        string $parentId = null,
36
        string $taskId = null
37
    ) {
38
        $this->title = $title;
39
        $this->description = $description;
40
        $this->creatorId = $creatorId;
41
        $this->assigneeId = $assigneeId;
42
        $this->priority = $priority;
43
        $this->projectId = $projectId;
44
        $this->parentId = $parentId;
45
        $this->taskId = $taskId;
46
    }
47
48
    public function title() : string
49
    {
50
        return $this->title;
51
    }
52
53
    public function description() : string
54
    {
55
        return $this->description;
56
    }
57
58
    public function creatorId() : string
59
    {
60
        return $this->creatorId;
61
    }
62
63
    public function assigneeId() : string
64
    {
65
        return $this->assigneeId;
66
    }
67
68
    public function priority() : string
69
    {
70
        return $this->priority;
71
    }
72
73
    public function projectId() : string
74
    {
75
        return $this->projectId;
76
    }
77
78
    public function parentId()
79
    {
80
        return $this->parentId;
81
    }
82
83
    public function taskId()
84
    {
85
        return $this->taskId;
86
    }
87
}
88