GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SerializerTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 87.5 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 56
loc 64
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testCollectionWithDefaultResourceKey() 8 8 1
A testCollectionWithCustomResourceKey() 8 8 1
A testCollectionWithOptionalResourceKey() 12 12 1
A testItemWithDefaultResourceKey() 8 8 1
A testItemWithCustomResourceKey() 8 8 1
A testItemWithOptionalResourceKey() 12 12 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 EllipseSynergie\ApiResponse\Tests\Serializer;
4
5
use EllipseSynergie\ApiResponse\Serializer\Serializer;
6
use PHPUnit_Framework_TestCase;
7
8
/**
9
 * Class SerializerTest
10
 * @package EllipseSynergie\ApiResponse\Tests\Serializer
11
 * @author Maxime Beaudoin <[email protected]>
12
 */
13
class SerializerTest extends PHPUnit_Framework_TestCase
14
{
15 View Code Duplication
    public function testCollectionWithDefaultResourceKey()
16
    {
17
        $data = ['foo'];
18
        $serializer = new Serializer();
19
        $result = $serializer->collection(null, $data);
20
21
        $this->assertSame(['data' => $data], $result);
22
    }
23
24 View Code Duplication
    public function testCollectionWithCustomResourceKey()
25
    {
26
        $data = ['foo'];
27
        $serializer = new Serializer();
28
        $result = $serializer->collection('custom', $data);
29
30
        $this->assertSame(['custom' => $data], $result);
31
    }
32
33 View Code Duplication
    public function testCollectionWithOptionalResourceKey()
34
    {
35
        $data = ['foo'];
36
        $serializer = new OptionalKeySerializer();
37
        $result = $serializer->collection(null, $data);
38
39
        $this->assertSame($data, $result);
40
41
        $result = $serializer->collection('optional', $data);
42
43
        $this->assertSame(['optional' => $data], $result);
44
    }
45
46 View Code Duplication
    public function testItemWithDefaultResourceKey()
47
    {
48
        $data = ['foo'];
49
        $serializer = new Serializer();
50
        $result = $serializer->item(null, $data);
51
52
        $this->assertSame(['data' => $data], $result);
53
    }
54
55 View Code Duplication
    public function testItemWithCustomResourceKey()
56
    {
57
        $data = ['foo'];
58
        $serializer = new Serializer();
59
        $result = $serializer->collection('custom', $data);
60
61
        $this->assertSame(['custom' => $data], $result);
62
    }
63
64 View Code Duplication
    public function testItemWithOptionalResourceKey()
65
    {
66
        $data = ['foo'];
67
        $serializer = new OptionalKeySerializer();
68
        $result = $serializer->item(null, $data);
69
70
        $this->assertSame($data, $result);
71
72
        $result = $serializer->item('optional', $data);
73
74
        $this->assertSame(['optional' => $data], $result);
75
    }
76
}
77