Completed
Push — master ( bd630a...f47f8d )
by Steve
01:55
created

JsonSpec   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 50 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 8
loc 16
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_uses_the_json_encode_function_of_the_dice() 8 8 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\MeadSteve\DiceApi\Renderer;
4
5
use MeadSteve\DiceApi\Dice;
6
use PhpSpec\ObjectBehavior;
7
use Prophecy\Argument;
8
9
class JsonSpec extends ObjectBehavior
10
{
11
    function it_is_initializable()
12
    {
13
        $this->shouldHaveType(\MeadSteve\DiceApi\Renderer\Json::class);
14
    }
15
16 View Code Duplication
    function it_uses_the_json_encode_function_of_the_dice(Dice $dice)
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...
17
    {
18
        $dice->roll()->willReturn(5);
19
        $dice->name()->willReturn("d6");
20
21
        $expectedJson = '{"success":true,"dice":[{"value":5,"type":"d6"}]}';
22
        $this->renderDice([$dice])->shouldReturn($expectedJson);
23
    }
24
}
25