Passed
Pull Request — master (#12)
by romain
09:45
created

CategoryArticleUnpublishMessageSpec   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 20
loc 20
rs 10
c 0
b 0
f 0

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
namespace spec\Yproximite\Api\Message\Article;
4
5
use PhpSpec\ObjectBehavior;
6
7
use Yproximite\Api\Message\Article\CategoryArticleUnpublishMessage;
8
9
class CategoryArticleUnpublishMessageSpec extends ObjectBehavior
10
{
11
    function it_is_initializable()
12
    {
13
        $this->shouldHaveType(CategoryArticleUnpublishMessage::class);
14
    }
15
16
    function it_should_build()
17
    {
18
        $this->setCategoryId(5);
19
        $this->setArticleIds([1, 2]);
20
21
        $data = [
22
            'category' => 5,
23
            'articles' => [1, 2],
24
        ];
25
26
        $this->build()->shouldReturn($data);
27
    }
28
}
29