Test Setup Failed
Push — master ( 051002...08cf0f )
by he
17:49
created

UserSolutions::getResolvedProblems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 6
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
4
namespace App\Services\User;
5
6
7
use App\Entities\Solution;
8
use App\Entities\User;
9
use App\Repositories\Criteria\Distinct;
10
use App\Repositories\Criteria\Where;
11
use App\Repositories\SolutionRepository;
12
use App\Status;
13
14
class UserSolutions
15
{
16
    public function getResolvedProblems(User $user) {
17
        /** @var SolutionRepository $repository */
18
        $repository = app(SolutionRepository::class);
19
        $repository->pushCriteria(new Where('user_id', $user->id));
20
        $repository->pushCriteria(new Where('result', Status::ACCEPT));
21
        $repository->pushCriteria(new Distinct('problem_id'));
22
        return $repository->all('problem_id')->map(function ($item) {
0 ignored issues
show
Bug introduced by
'problem_id' of type string is incompatible with the type array expected by parameter $columns of Czim\Repository\BaseRepository::all(). ( Ignorable by Annotation )

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

22
        return $repository->all(/** @scrutinizer ignore-type */ 'problem_id')->map(function ($item) {
Loading history...
23
            return $item->problem_id;
24
        });
25
    }
26
}
27