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

CategoryPostMessageSpec   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 75 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 24
loc 32
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\CategoryPostMessage;
8
use Yproximite\Api\Message\Article\CategoryTranslationMessage;
9
10
class CategoryPostMessageSpec extends ObjectBehavior
11
{
12
    function it_is_initializable()
13
    {
14
        $this->shouldHaveType(CategoryPostMessage::class);
15
    }
16
17
    function it_should_build()
18
    {
19
        $translation = new CategoryTranslationMessage();
20
        $translation->setLocale('en');
21
        $translation->setTitle('English title');
22
        $translation->setDescription('English description');
23
24
        $this->setParentRootId(11);
25
        $this->setEnabled(true);
26
        $this->addTranslation($translation);
27
28
        $transData = [
29
            'title'       => 'English title',
30
            'description' => 'English description',
31
        ];
32
33
        $data = [
34
            'parentRootId' => 11,
35
            'enabled'      => true,
36
            'translations' => ['en' => $transData],
37
        ];
38
39
        $this->build()->shouldReturn($data);
40
    }
41
}
42