OffsetLimitCriterion   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A apply() 0 7 1
1
<?php
2
3
namespace Napp\Core\Dbal\Criteria;
4
5
class OffsetLimitCriterion implements CriterionInterface
6
{
7
    /**
8
     * @var int
9
     */
10
    protected $offset;
11
12
    /**
13
     * @var int
14
     */
15
    protected $limit;
16
17
    /**
18
     * @param int $offset
19
     * @param int $limit
20
     */
21
    public function __construct($offset = 0, $limit = 30)
22
    {
23
        $this->offset = $offset;
24
        $this->limit = $limit;
25
    }
26
27
    /**
28
     * @param \Illuminate\Database\Eloquent\Builder $query
29
     *
30
     * @return \Illuminate\Database\Eloquent\Builder
31
     */
32
    public function apply($query)
33
    {
34
        $query->getQuery()->skip($this->offset);
35
        $query->getQuery()->take($this->limit);
36
37
        return $query;
38
    }
39
}
40