Test Failed
Pull Request — master (#116)
by Zing
04:20
created

Pageable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A enablePaginator() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zing\QueryBuilder\Concerns;
6
7
use Zing\QueryBuilder\Paginator;
8
9
trait Pageable
10
{
11
    /**
12
     * @param string|\Zing\QueryBuilder\Paginator $paginator
13
     *
14
     * @return $this
15
     */
16
    public function enablePaginator(?string $paginator = null)
17
    {
18
        $paginator = $paginator instanceof Paginator ? $paginator : Paginator::name($paginator);
19
        $perPage = $this->request->input($paginator->getName(), $paginator->getDefault());
20
        $this->builder->getModel()
21
            ->setPerPage($perPage);
22
23
        return $this;
24
    }
25
}
26