Passed
Push — develop ( 605aab...b17d99 )
by Stone
06:54 queued 11s
created

PaginateRepositoryTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 6
dl 0
loc 11
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A paginate() 0 9 1
1
<?php
2
3
namespace App\Pagination;
4
5
6
use Doctrine\ORM\Tools\Pagination\Paginator;
7
8
trait PaginateRepositoryTrait{
9
10
    public function paginate($dql, int $limit, int $page = 1)
11
    {
12
        $paginator = new Paginator($dql);
13
14
        $paginator->getQuery()
15
            ->setFirstResult($limit * ($page - 1))// Offset
16
            ->setMaxResults($limit); // Limit
17
18
        return $paginator;
19
    }
20
}