Passed
Pull Request — master (#223)
by Alexander
05:30
created

UserRepository::findAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\User;
6
7
use Cycle\ORM\Select;
8
use Yiisoft\Auth\IdentityInterface;
9
use Yiisoft\Auth\IdentityRepositoryInterface;
10
use Yiisoft\Data\Reader\DataReaderInterface;
11
use Yiisoft\Yii\Cycle\Data\Reader\EntityReader;
12
13
class UserRepository extends Select\Repository implements IdentityRepositoryInterface
14
{
15 1
    public function findAll(array $scope = [], array $orderBy = []): DataReaderInterface
16
    {
17 1
        return new EntityReader($this->select()->where($scope)->orderBy($orderBy));
18
    }
19
20
    private function findIdentityBy(string $field, string $value): ?IdentityInterface
21
    {
22
        return $this->findOne([$field => $value]);
23
    }
24
25
    /**
26
     * @param string $id
27
     *
28
     * @return IdentityInterface|User|null
29
     */
30
    public function findIdentity(string $id): ?IdentityInterface
31
    {
32
        return $this->findByPK($id);
33
    }
34
35
    public function findIdentityByToken(string $token, string $type = null): ?IdentityInterface
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

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

35
    public function findIdentityByToken(string $token, /** @scrutinizer ignore-unused */ string $type = null): ?IdentityInterface

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        return $this->findIdentityBy('token', $token);
38
    }
39
40
    public function findByLogin(string $login): ?IdentityInterface
41
    {
42
        return $this->findIdentityBy('login', $login);
43
    }
44
}
45