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

UserSolutions   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 10
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getResolvedProblems() 0 8 1
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