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

UserPostMessageSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 51.28 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 20
loc 39
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\User;
4
5
use PhpSpec\ObjectBehavior;
6
7
use Yproximite\Api\Exception\LogicException;
8
use Yproximite\Api\Message\User\UserPostMessage;
9
10
class UserPostMessageSpec extends ObjectBehavior
11
{
12
    function it_is_initializable()
13
    {
14
        $this->shouldHaveType(UserPostMessage::class);
15
    }
16
17
    function it_should_build()
18
    {
19
        $this->setFirstName('Example');
20
        $this->setLastName('');
21
        $this->setEmail('[email protected]');
22
        $this->setPlainPassword('12345');
23
        $this->setPhone('+1 234 567 890');
24
        $this->setDefaultLocale('en');
25
26
        $data = [
27
            'firstName'     => 'Example',
28
            'lastName'      => '',
29
            'email'         => '[email protected]',
30
            'plainPassword' => '12345',
31
            'phone'         => '+1 234 567 890',
32
            'defaultLocale' => 'en',
33
        ];
34
35
        $this->build()->shouldReturn($data);
36
    }
37
38
    function it_should_ask_for_plain_password()
39
    {
40
        $this->setFirstName('Example');
41
        $this->setLastName('');
42
        $this->setEmail('[email protected]');
43
        $this->setPhone('+1 234 567 890');
44
        $this->setDefaultLocale('en');
45
46
        $this->shouldThrow(LogicException::class)->during('build');
47
    }
48
}
49