Completed
Branch develop (bb7f99)
by Victor
03:01 queued 27s
created

PaginatorWithPages   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 24
ccs 5
cts 10
cp 0.5
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentPage() 0 8 1
A getCountPages() 0 8 1
1
<?php
2
3
namespace AppBundle\Model;
4
5
use Doctrine\ORM\Tools\Pagination\Paginator;
6
7
class PaginatorWithPages extends Paginator
8
{
9
    private $currentPage;
10
11
    private $countPages;
12
13
    public function getCurrentPage()
14
    {
15
        $firstResult = $this->getQuery()->getFirstResult();
16
        $maxResults = $this->getQuery()->getMaxResults();
17
        $currentPage = $firstResult / $maxResults + 1;
18
19
        return $this->currentPage = $currentPage;
20
    }
21
22 6
    public function getCountPages()
23
    {
24 6
        $countResults = $this->count();
25 6
        $maxResults = $this->getQuery()->getMaxResults();
26 6
        $countPages = ceil($countResults / $maxResults);
27
28 6
        return $this->countPages = $countPages;
29
    }
30
}