TopicService::topicsForContest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace App\Services;
4
5
use App\Repositories\Criteria\OrderBy;
6
use App\Repositories\Criteria\Where;
7
use App\Repositories\TopicRepository;
8
9
class TopicService
10
{
11
    private $repository;
12
13
    /**
14
     * TopicService constructor.
15
     */
16
    public function __construct()
17
    {
18
        $this->repository = app(TopicRepository::class);
19
    }
20
21
    public function topicsForContest($contestId)
22
    {
23
        $this->repository->pushCriteria(new Where('contest_id', $contestId));
24
        $this->repository->pushCriteria(new OrderBy('created_at', 'desc'));
25
26
        return $this->repository->paginate(request('per_page', 50));
0 ignored issues
show
Bug introduced by
request('per_page', 50) of type Illuminate\Http\Request|array|string is incompatible with the type integer expected by parameter $perPage of Czim\Repository\BaseRepository::paginate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        return $this->repository->paginate(/** @scrutinizer ignore-type */ request('per_page', 50));
Loading history...
27
    }
28
}
29