Passed
Pull Request — master (#116)
by Zing
09:46 queued 04:37
created

Pageable::enablePaginator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 10
c 1
b 0
f 0
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(string $paginator)
17
    {
18 2
        $paginator = is_string($paginator) ? Paginator::name($paginator) : $paginator;
0 ignored issues
show
introduced by
The condition is_string($paginator) is always true.
Loading history...
19 2
        $this->builder->getModel()
20 2
            ->setPerPage($this->request->input($paginator->getName(), $paginator->getDefault()));
21
22 2
        return $this;
23
    }
24
}
25