Passed
Push — master ( 45291c...cb5044 )
by David
01:16
created

PaginationTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 50 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 19
loc 38
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testInstanceOf() 0 4 1
A testPage() 10 10 1
A testLimit() 9 9 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 FlexyProject\GitHub\Tests;
4
5
use FlexyProject\GitHub\Client;
6
use FlexyProject\GitHub\Pagination;
7
use FlexyProject\GitHub\Receiver\Activity;
8
9
/**
10
 * Class PaginationTest
11
 *
12
 * @package FlexyProject\GitHub\Tests
13
 */
14
class PaginationTest extends AbstractClientTest
15
{
16
17
    /** @var Pagination */
18
    protected $pagination;
19
20
    public function setUp()
21
    {
22
        $this->pagination = new Pagination();
23
        $this->client->setPagination($this->pagination);
24
    }
25
26
    public function testInstanceOf()
27
    {
28
        self::assertInstanceOf(Pagination::class, $this->pagination);
29
    }
30
31 View Code Duplication
    public function testPage()
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...
32
    {
33
        $this->pagination->setLimit(10);
34
        $this->pagination->setPage(2);
35
        self::assertEquals(2, $this->pagination->getPage());
36
37
        $activity = $this->client->getReceiver(Client::ACTIVITY);
38
        $events   = $activity->getReceiver(Activity::EVENTS);
39
        self::assertCount(10, $events->listPublicEvents());
40
    }
41
42 View Code Duplication
    public function testLimit()
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...
43
    {
44
        $this->pagination->setLimit(10);
45
        self::assertEquals(10, $this->pagination->getLimit());
46
47
        $activity = $this->client->getReceiver(Client::ACTIVITY);
48
        $events   = $activity->getReceiver(Activity::EVENTS);
49
        self::assertCount(10, $events->listPublicEvents());
50
    }
51
}