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

FieldPostMessageSpec   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 73.33 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 22
loc 30
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\Field;
4
5
use PhpSpec\ObjectBehavior;
6
7
use Yproximite\Api\Message\Field\FieldPostMessage;
8
use Yproximite\Api\Message\Field\FieldTranslationMessage;
9
10
class FieldPostMessageSpec extends ObjectBehavior
11
{
12
    function it_is_initializable()
13
    {
14
        $this->shouldHaveType(FieldPostMessage::class);
15
    }
16
17
    function it_should_build()
18
    {
19
        $translation = new FieldTranslationMessage();
20
        $translation->setLocale('en');
21
        $translation->setValue('Secret');
22
23
        $this->setToken('some-field');
24
        $this->setDescription('Some description');
25
        $this->addTranslation($translation);
26
27
        $transData = [
28
            'value' => 'Secret',
29
        ];
30
31
        $data = [
32
            'token' => 'some-field',
33
            'description' => 'Some description',
34
            'translations' => ['en' => $transData],
35
        ];
36
37
        $this->build()->shouldReturn($data);
38
    }
39
}
40