FilterTasksQuerySpec   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 125
Duplicated Lines 69.6 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 87
loc 125
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A it_can_be_created() 0 14 1
A it_can_be_created_with_title() 14 14 1
A it_can_be_created_with_priority() 14 14 1
A it_can_be_created_with_progress() 14 14 1
A it_can_be_created_with_parent_id() 0 14 1
A it_can_be_created_with_project_id() 15 15 1
A it_can_be_created_with_assignee_id() 15 15 1
A it_can_be_created_with_reporter_id() 15 15 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 Spec\Kreta\TaskManager\Application\Query\Project\Task;
16
17
use Kreta\TaskManager\Application\Query\Project\Task\FilterTasksQuery;
18
use PhpSpec\ObjectBehavior;
19
20
class FilterTasksQuerySpec extends ObjectBehavior
21
{
22
    function it_can_be_created()
23
    {
24
        $this->beConstructedWith('user-id', 0, -1);
25
        $this->shouldHaveType(FilterTasksQuery::class);
26
        $this->userId()->shouldReturn('user-id');
27
        $this->offset()->shouldReturn(0);
28
        $this->limit()->shouldReturn(-1);
29
        $this->title()->shouldReturn(null);
30
        $this->parentId()->shouldReturn(null);
31
        $this->priority()->shouldReturn(null);
32
        $this->progress()->shouldReturn(null);
33
        $this->assigneeId()->shouldReturn(null);
34
        $this->reporterId()->shouldReturn(null);
35
    }
36
37 View Code Duplication
    function it_can_be_created_with_title()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $this->beConstructedWith('user-id', 0, -1, null, null, 'Task title');
40
        $this->shouldHaveType(FilterTasksQuery::class);
41
        $this->userId()->shouldReturn('user-id');
42
        $this->offset()->shouldReturn(0);
43
        $this->limit()->shouldReturn(-1);
44
        $this->title()->shouldReturn('Task title');
45
        $this->parentId()->shouldReturn(null);
46
        $this->priority()->shouldReturn(null);
47
        $this->progress()->shouldReturn(null);
48
        $this->assigneeId()->shouldReturn(null);
49
        $this->reporterId()->shouldReturn(null);
50
    }
51
52 View Code Duplication
    function it_can_be_created_with_priority()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54
        $this->beConstructedWith('user-id', 0, -1, null, null, null, 'low');
55
        $this->shouldHaveType(FilterTasksQuery::class);
56
        $this->userId()->shouldReturn('user-id');
57
        $this->offset()->shouldReturn(0);
58
        $this->limit()->shouldReturn(-1);
59
        $this->title()->shouldReturn(null);
60
        $this->parentId()->shouldReturn(null);
61
        $this->priority()->shouldReturn('low');
62
        $this->progress()->shouldReturn(null);
63
        $this->assigneeId()->shouldReturn(null);
64
        $this->reporterId()->shouldReturn(null);
65
    }
66
67 View Code Duplication
    function it_can_be_created_with_progress()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
    {
69
        $this->beConstructedWith('user-id', 0, -1, null, null, null, null, 'todo');
70
        $this->shouldHaveType(FilterTasksQuery::class);
71
        $this->userId()->shouldReturn('user-id');
72
        $this->offset()->shouldReturn(0);
73
        $this->limit()->shouldReturn(-1);
74
        $this->title()->shouldReturn(null);
75
        $this->parentId()->shouldReturn(null);
76
        $this->priority()->shouldReturn(null);
77
        $this->progress()->shouldReturn('todo');
78
        $this->assigneeId()->shouldReturn(null);
79
        $this->reporterId()->shouldReturn(null);
80
    }
81
82
    function it_can_be_created_with_parent_id()
83
    {
84
        $this->beConstructedWith('user-id', 0, -1, 'parent-id');
85
        $this->shouldHaveType(FilterTasksQuery::class);
86
        $this->userId()->shouldReturn('user-id');
87
        $this->offset()->shouldReturn(0);
88
        $this->limit()->shouldReturn(-1);
89
        $this->title()->shouldReturn(null);
90
        $this->parentId()->shouldReturn('parent-id');
91
        $this->priority()->shouldReturn(null);
92
        $this->progress()->shouldReturn(null);
93
        $this->assigneeId()->shouldReturn(null);
94
        $this->reporterId()->shouldReturn(null);
95
    }
96
97 View Code Duplication
    function it_can_be_created_with_project_id()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
98
    {
99
        $this->beConstructedWith('user-id', 0, -1, null, 'project-id');
100
        $this->shouldHaveType(FilterTasksQuery::class);
101
        $this->userId()->shouldReturn('user-id');
102
        $this->offset()->shouldReturn(0);
103
        $this->limit()->shouldReturn(-1);
104
        $this->title()->shouldReturn(null);
105
        $this->parentId()->shouldReturn(null);
106
        $this->projectId()->shouldReturn('project-id');
107
        $this->priority()->shouldReturn(null);
108
        $this->progress()->shouldReturn(null);
109
        $this->assigneeId()->shouldReturn(null);
110
        $this->reporterId()->shouldReturn(null);
111
    }
112
113 View Code Duplication
    function it_can_be_created_with_assignee_id()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
114
    {
115
        $this->beConstructedWith('user-id', 0, -1, null, null, null, null, null, 'assignee-id');
116
        $this->shouldHaveType(FilterTasksQuery::class);
117
        $this->userId()->shouldReturn('user-id');
118
        $this->offset()->shouldReturn(0);
119
        $this->limit()->shouldReturn(-1);
120
        $this->title()->shouldReturn(null);
121
        $this->parentId()->shouldReturn(null);
122
        $this->projectId()->shouldReturn(null);
123
        $this->priority()->shouldReturn(null);
124
        $this->progress()->shouldReturn(null);
125
        $this->assigneeId()->shouldReturn('assignee-id');
126
        $this->reporterId()->shouldReturn(null);
127
    }
128
129 View Code Duplication
    function it_can_be_created_with_reporter_id()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
130
    {
131
        $this->beConstructedWith('user-id', 0, -1, null, null, null, null, null, null, 'reporter-id');
132
        $this->shouldHaveType(FilterTasksQuery::class);
133
        $this->userId()->shouldReturn('user-id');
134
        $this->offset()->shouldReturn(0);
135
        $this->limit()->shouldReturn(-1);
136
        $this->title()->shouldReturn(null);
137
        $this->parentId()->shouldReturn(null);
138
        $this->projectId()->shouldReturn(null);
139
        $this->priority()->shouldReturn(null);
140
        $this->progress()->shouldReturn(null);
141
        $this->assigneeId()->shouldReturn(null);
142
        $this->reporterId()->shouldReturn('reporter-id');
143
    }
144
}
145