Passed
Pull Request — master (#116)
by Zing
05:30
created

Pageable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A enablePaginator() 0 7 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 2
    public function enablePaginator($paginator)
17
    {
18 2
        $paginator = is_string($paginator) ? Paginator::name($paginator) : $paginator;
19 2
        $this->builder->getModel()
20 2
            ->setPerPage($this->request->input($paginator->getName(), $paginator->getDefault()));
21
22 2
        return $this;
23
    }
24
}
25