Issues (34)

src/Criteria/LimitBy.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Noitran\Repositories\Criteria;
6
7
use Illuminate\Database\Eloquent\Builder;
8
use Noitran\Repositories\Contracts\Criteria\CriteriaInterface;
9
use Noitran\Repositories\Contracts\Repository\RepositoryInterface;
10
11
/**
12
 * Class LimitBy.
13
 */
14
class LimitBy implements CriteriaInterface
15
{
16
    /**
17
     * @var string
18
     */
19
    protected $count;
20
21
    /**
22
     * LimitBy constructor.
23
     *
24 1
     * @param $count
25
     */
26 1
    public function __construct($count)
27 1
    {
28
        $this->count = $count;
29
    }
30
31
    /**
32
     * @param Builder $model
33
     * @param RepositoryInterface $repository
34
     *
35 1
     * @return Builder
36
     */
37 1
    public function apply($model, RepositoryInterface $repository) //: Builder
38 1
    {
39
        if ($this->count) {
40
            return $model->limit($this->count);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $model->limit($this->count) also could return the type Illuminate\Database\Query\Builder which is incompatible with the documented return type Illuminate\Database\Eloquent\Builder.
Loading history...
41
        }
42
43
        return $model;
44
    }
45
}
46