PhalconFrameworkPaginatorAdapterTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testPaginationAdapter() 0 21 1
1
<?php
2
3
namespace League\Fractal\Test\Pagination;
4
5
use League\Fractal\Pagination\PhalconFrameworkPaginatorAdapter;
6
use PHPUnit\Framework\TestCase;
7
8
class PhalconFrameworkPaginatorAdapterTest extends TestCase
9
{
10
    public function testPaginationAdapter()
11
    {
12
        $resultset = new \stdClass();
13
        $resultset->items       = array_fill(1, 10, 'fractal');
14
        $resultset->current     = 3;
15
        $resultset->first       = 1;
16
        $resultset->last        = 5;
17
        $resultset->next        = 4;
18
        $resultset->previous    = 2;
19
        $resultset->total_items = 50;
20
        $resultset->total_pages = 10;
21
22
        $adapter = new PhalconFrameworkPaginatorAdapter($resultset);
0 ignored issues
show
Documentation introduced by Nikolaos Dimopoulos
$resultset is of type object<stdClass>, but the function expects a object<League\Fractal\Pagination\stdClass>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
23
        $this->assertInstanceOf('League\Fractal\Pagination\PaginatorInterface', $adapter);
24
        $this->assertSame(3, $adapter->getCurrentPage());
25
        $this->assertSame(10, $adapter->getCount());
26
        $this->assertSame(50, $adapter->getTotal());
27
        $this->assertSame(10, $adapter->getPerPage());
28
        $this->assertSame(5, $adapter->getLastPage());
29
        $this->assertSame(4, $adapter->getNext());
30
    }
31
}
32