GridSourcePager   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 13
dl 0
loc 34
rs 10
c 2
b 1
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getRange() 0 2 1
A getCurrentPage() 0 10 2
A getTotalPages() 0 8 2
A __construct() 0 3 1
1
<?php
2
3
namespace Dtc\GridBundle\Grid\Pager;
4
5
use Dtc\GridBundle\Grid\Source\GridSourceInterface;
6
7
class GridSourcePager extends Pager
8
{
9
    private $gridSource;
10
    private $totalPages;
0 ignored issues
show
introduced by
The private property $totalPages is not used, and could be removed.
Loading history...
11
12
    public function __construct(GridSourceInterface $gridSource)
13
    {
14
        $this->gridSource = $gridSource;
15
    }
16
17
    public function getCurrentPage()
18
    {
19
        $limit = $this->gridSource->getLimit();
20
        $offset = $this->gridSource->getOffset();
21
22
        if (!$limit) {
23
            return $offset;
24
        }
25
26
        return ceil(($offset / $limit) + 1);
27
    }
28
29
    public function getTotalPages()
30
    {
31
        $limit = $this->gridSource->getLimit();
32
        if (!$limit) {
33
            return $this->gridSource->getCount();
34
        }
35
36
        return ceil($this->gridSource->getCount() / $limit);
37
    }
38
39
    public function getRange($delta)
0 ignored issues
show
Unused Code introduced by
The parameter $delta is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    public function getRange(/** @scrutinizer ignore-unused */ $delta)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
    }
42
}
43