CountTasksQuery::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

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

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\Query\Project\Task;
16
17
class CountTasksQuery
18
{
19
    private $userId;
20
    private $projectId;
21
    private $title;
22
    private $parentId;
23
    private $priority;
24
    private $progress;
25
    private $assigneeId;
26
    private $reporterId;
27
28
    public function __construct(
29
        string $userId,
30
        string $parentId = null,
31
        string $projectId = null,
32
        string $title = null,
33
        string $priority = null,
34
        string $progress = null,
35
        string $assigneeId = null,
36
        string $reporterId = null
37
    ) {
38
        $this->userId = $userId;
39
        $this->title = $title;
40
        $this->projectId = $projectId;
41
        $this->parentId = $parentId;
42
        $this->priority = $priority;
43
        $this->progress = $progress;
44
        $this->assigneeId = $assigneeId;
45
        $this->reporterId = $reporterId;
46
    }
47
48
    public function userId() : string
49
    {
50
        return $this->userId;
51
    }
52
53
    public function projectId() : ? string
54
    {
55
        return $this->projectId;
56
    }
57
58
    public function title() : ? string
59
    {
60
        return $this->title;
61
    }
62
63
    public function parentId()
64
    {
65
        return $this->parentId;
66
    }
67
68
    public function priority()
69
    {
70
        return $this->priority;
71
    }
72
73
    public function progress()
74
    {
75
        return $this->progress;
76
    }
77
78
    public function assigneeId()
79
    {
80
        return $this->assigneeId;
81
    }
82
83
    public function reporterId()
84
    {
85
        return $this->reporterId;
86
    }
87
}
88