UserPostMessageSpec   A
last analyzed

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_should_build() 20 20 1
A it_should_ask_for_plain_password() 0 10 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
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 View Code Duplication
    function it_should_build()
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...
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