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.

testGenerateAbsoluteURIs()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 90
Code Lines 57

Duplication

Lines 90
Ratio 100 %

Importance

Changes 0
Metric Value
dl 90
loc 90
c 0
b 0
f 0
rs 8.5454
cc 1
eloc 57
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Hateoas\Tests\Representation;
4
5
use Hateoas\Representation\CollectionRepresentation;
6
use Hateoas\Representation\PaginatedRepresentation;
7
use Hateoas\Tests\Fixtures\UsersRepresentation;
8
9
class PaginatedRepresentationTest extends RepresentationTestCase
10
{
11 View Code Duplication
    public function testSerialize()
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...
12
    {
13
        $collection = new PaginatedRepresentation(
14
            new CollectionRepresentation(
15
                array(
16
                    'Adrien',
17
                    'William',
18
                ),
19
                'authors',
20
                'users'
21
            ),
22
            '/authors',
23
            array(
24
                'query' => 'willdurand/Hateoas',
25
            ),
26
            3,
27
            20,
28
            17,
29
            null,
30
            null,
31
            false,
32
            100
33
        );
34
35
        $this->assertSame(
36
            <<<XML
37
<?xml version="1.0" encoding="UTF-8"?>
38
<collection page="3" limit="20" pages="17" total="100">
39
  <users rel="authors">
40
    <entry><![CDATA[Adrien]]></entry>
41
    <entry><![CDATA[William]]></entry>
42
  </users>
43
  <link rel="self" href="/authors?query=willdurand%2FHateoas&amp;page=3&amp;limit=20"/>
44
  <link rel="first" href="/authors?query=willdurand%2FHateoas&amp;page=1&amp;limit=20"/>
45
  <link rel="last" href="/authors?query=willdurand%2FHateoas&amp;page=17&amp;limit=20"/>
46
  <link rel="next" href="/authors?query=willdurand%2FHateoas&amp;page=4&amp;limit=20"/>
47
  <link rel="previous" href="/authors?query=willdurand%2FHateoas&amp;page=2&amp;limit=20"/>
48
</collection>
49
50
XML
51
            ,
52
            $this->hateoas->serialize($collection, 'xml')
53
        );
54
        $this->assertSame(
55
            <<<XML
56
<?xml version="1.0" encoding="UTF-8"?>
57
<collection page="3" limit="20" pages="17" total="100" href="/authors?query=willdurand%2FHateoas&amp;page=3&amp;limit=20">
58
  <resource rel="authors"><![CDATA[Adrien]]></resource>
59
  <resource rel="authors"><![CDATA[William]]></resource>
60
  <link rel="first" href="/authors?query=willdurand%2FHateoas&amp;page=1&amp;limit=20"/>
61
  <link rel="last" href="/authors?query=willdurand%2FHateoas&amp;page=17&amp;limit=20"/>
62
  <link rel="next" href="/authors?query=willdurand%2FHateoas&amp;page=4&amp;limit=20"/>
63
  <link rel="previous" href="/authors?query=willdurand%2FHateoas&amp;page=2&amp;limit=20"/>
64
</collection>
65
66
XML
67
            ,
68
            $this->halHateoas->serialize($collection, 'xml')
69
        );
70
        $this->assertSame(
71
            <<<XML
72
<?xml version="1.0" encoding="UTF-8"?>
73
<users page="3" limit="20" pages="17" total="100">
74
  <users rel="authors">
75
    <entry><![CDATA[Adrien]]></entry>
76
    <entry><![CDATA[William]]></entry>
77
  </users>
78
  <link rel="self" href="/authors?query=willdurand%2FHateoas&amp;page=3&amp;limit=20"/>
79
  <link rel="first" href="/authors?query=willdurand%2FHateoas&amp;page=1&amp;limit=20"/>
80
  <link rel="last" href="/authors?query=willdurand%2FHateoas&amp;page=17&amp;limit=20"/>
81
  <link rel="next" href="/authors?query=willdurand%2FHateoas&amp;page=4&amp;limit=20"/>
82
  <link rel="previous" href="/authors?query=willdurand%2FHateoas&amp;page=2&amp;limit=20"/>
83
</users>
84
85
XML
86
            ,
87
            $this->hateoas->serialize(new UsersRepresentation($collection), 'xml')
88
        );
89
        $this->assertSame(
90
            <<<XML
91
<?xml version="1.0" encoding="UTF-8"?>
92
<users page="3" limit="20" pages="17" total="100" href="/authors?query=willdurand%2FHateoas&amp;page=3&amp;limit=20">
93
  <resource rel="authors"><![CDATA[Adrien]]></resource>
94
  <resource rel="authors"><![CDATA[William]]></resource>
95
  <link rel="first" href="/authors?query=willdurand%2FHateoas&amp;page=1&amp;limit=20"/>
96
  <link rel="last" href="/authors?query=willdurand%2FHateoas&amp;page=17&amp;limit=20"/>
97
  <link rel="next" href="/authors?query=willdurand%2FHateoas&amp;page=4&amp;limit=20"/>
98
  <link rel="previous" href="/authors?query=willdurand%2FHateoas&amp;page=2&amp;limit=20"/>
99
</users>
100
101
XML
102
            ,
103
            $this->halHateoas->serialize(new UsersRepresentation($collection), 'xml')
104
        );
105
        $this->assertSame(
106
            '{'
107
                .'"page":3,'
108
                .'"limit":20,'
109
                .'"pages":17,'
110
                .'"total":100,'
111
                .'"_links":{'
112
                    .'"self":{'
113
                        .'"href":"\/authors?query=willdurand%2FHateoas&page=3&limit=20"'
114
                    .'},'
115
                    .'"first":{'
116
                        .'"href":"\/authors?query=willdurand%2FHateoas&page=1&limit=20"'
117
                    .'},'
118
                    .'"last":{'
119
                        .'"href":"\/authors?query=willdurand%2FHateoas&page=17&limit=20"'
120
                    .'},'
121
                    .'"next":{'
122
                        .'"href":"\/authors?query=willdurand%2FHateoas&page=4&limit=20"'
123
                    .'},'
124
                    .'"previous":{'
125
                        .'"href":"\/authors?query=willdurand%2FHateoas&page=2&limit=20"'
126
                    .'}'
127
                .'},'
128
                .'"_embedded":{'
129
                    .'"authors":['
130
                        .'"Adrien",'
131
                        .'"William"'
132
                    .']'
133
                .'}'
134
            .'}',
135
            $this->halHateoas->serialize($collection, 'json')
136
        );
137
    }
138
139 View Code Duplication
    public function testGenerateAbsoluteURIs()
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...
140
    {
141
        $collection = new PaginatedRepresentation(
142
            new CollectionRepresentation(
143
                array(
144
                    'Adrien',
145
                    'William',
146
                ),
147
                'authors',
148
                'users'
149
            ),
150
            '/authors',
151
            array(
152
                'query' => 'willdurand/Hateoas',
153
            ),
154
            3,
155
            20,
156
            17,
157
            null,
158
            null,
159
            true // force absolute URIs
160
        );
161
162
        $this->assertSame(
163
            <<<XML
164
<?xml version="1.0" encoding="UTF-8"?>
165
<collection page="3" limit="20" pages="17">
166
  <users rel="authors">
167
    <entry><![CDATA[Adrien]]></entry>
168
    <entry><![CDATA[William]]></entry>
169
  </users>
170
  <link rel="self" href="http://example.com/authors?query=willdurand%2FHateoas&amp;page=3&amp;limit=20"/>
171
  <link rel="first" href="http://example.com/authors?query=willdurand%2FHateoas&amp;page=1&amp;limit=20"/>
172
  <link rel="last" href="http://example.com/authors?query=willdurand%2FHateoas&amp;page=17&amp;limit=20"/>
173
  <link rel="next" href="http://example.com/authors?query=willdurand%2FHateoas&amp;page=4&amp;limit=20"/>
174
  <link rel="previous" href="http://example.com/authors?query=willdurand%2FHateoas&amp;page=2&amp;limit=20"/>
175
</collection>
176
177
XML
178
            ,
179
            $this->hateoas->serialize($collection, 'xml')
180
        );
181
        $this->assertSame(
182
            <<<XML
183
<?xml version="1.0" encoding="UTF-8"?>
184
<collection page="3" limit="20" pages="17" href="http://example.com/authors?query=willdurand%2FHateoas&amp;page=3&amp;limit=20">
185
  <resource rel="authors"><![CDATA[Adrien]]></resource>
186
  <resource rel="authors"><![CDATA[William]]></resource>
187
  <link rel="first" href="http://example.com/authors?query=willdurand%2FHateoas&amp;page=1&amp;limit=20"/>
188
  <link rel="last" href="http://example.com/authors?query=willdurand%2FHateoas&amp;page=17&amp;limit=20"/>
189
  <link rel="next" href="http://example.com/authors?query=willdurand%2FHateoas&amp;page=4&amp;limit=20"/>
190
  <link rel="previous" href="http://example.com/authors?query=willdurand%2FHateoas&amp;page=2&amp;limit=20"/>
191
</collection>
192
193
XML
194
            ,
195
            $this->halHateoas->serialize($collection, 'xml')
196
        );
197
        $this->assertSame(
198
            '{'
199
                .'"page":3,'
200
                .'"limit":20,'
201
                .'"pages":17,'
202
                .'"_links":{'
203
                    .'"self":{'
204
                        .'"href":"http:\/\/example.com\/authors?query=willdurand%2FHateoas&page=3&limit=20"'
205
                    .'},'
206
                    .'"first":{'
207
                        .'"href":"http:\/\/example.com\/authors?query=willdurand%2FHateoas&page=1&limit=20"'
208
                    .'},'
209
                    .'"last":{'
210
                        .'"href":"http:\/\/example.com\/authors?query=willdurand%2FHateoas&page=17&limit=20"'
211
                    .'},'
212
                    .'"next":{'
213
                        .'"href":"http:\/\/example.com\/authors?query=willdurand%2FHateoas&page=4&limit=20"'
214
                    .'},'
215
                    .'"previous":{'
216
                        .'"href":"http:\/\/example.com\/authors?query=willdurand%2FHateoas&page=2&limit=20"'
217
                    .'}'
218
                .'},'
219
                .'"_embedded":{'
220
                    .'"authors":['
221
                        .'"Adrien",'
222
                        .'"William"'
223
                    .']'
224
                .'}'
225
            .'}',
226
            $this->halHateoas->serialize($collection, 'json')
227
        );
228
    }
229
}
230