PrimitiveTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 44
loc 44
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetData() 6 6 1
A testGetTransformer() 11 11 1
A testSetResourceKey() 6 6 1
A testGetResourceKey() 7 7 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 namespace League\Fractal\Test\Resource;
2
3
use League\Fractal\Resource\Primitive;
4
use Mockery;
5
use PHPUnit\Framework\TestCase;
6
7 View Code Duplication
class PrimitiveTest extends TestCase
0 ignored issues
show
Duplication introduced by Željka Blažek
This class 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...
8
{
9
    protected $simplePrimitive = 'sample string';
10
11
    public function testGetData()
12
    {
13
        $primitive = new Primitive($this->simplePrimitive);
14
15
        $this->assertSame($primitive->getData(), $this->simplePrimitive);
16
    }
17
18
    public function testGetTransformer()
19
    {
20
        $primitive = new Primitive($this->simplePrimitive, function () {});
21
22
        $this->assertTrue(is_callable($primitive->getTransformer()));
23
24
        $transformer = 'thismightbeacallablestring';
25
        $primitive = new Primitive($this->simplePrimitive, $transformer);
26
27
        $this->assertSame($primitive->getTransformer(), $transformer);
28
    }
29
30
    /**
31
     * @covers \League\Fractal\Resource\Primitive::setResourceKey
32
     */
33
    public function testSetResourceKey()
34
    {
35
        $primitive = Mockery::mock('League\Fractal\Resource\Primitive')->makePartial();
36
37
        $this->assertSame($primitive, $primitive->setResourceKey('foo'));
38
    }
39
40
    /**
41
     * @covers \League\Fractal\Resource\Primitive::getResourceKey
42
     */
43
    public function testGetResourceKey()
44
    {
45
        $primitive = Mockery::mock('League\Fractal\Resource\Primitive')->makePartial();
46
        $primitive->setResourceKey('foo');
47
48
        $this->assertSame('foo', $primitive->getResourceKey());
49
    }
50
}
51