Completed
Push — master ( 3a917b...8faa80 )
by Alexander
15s queued 12s
created

UserRepository::findIdentityByToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace App\Repository;
4
5
use Cycle\ORM\Select;
6
use Yiisoft\Auth\IdentityInterface;
7
use Yiisoft\Auth\IdentityRepositoryInterface;
8
use Yiisoft\Yii\Cycle\DataReader\SelectDataReader;
9
10
class UserRepository extends Select\Repository implements IdentityRepositoryInterface
11
{
12
    public function findAll(array $scope = [], array $orderBy = []): SelectDataReader
13
    {
14
        return new SelectDataReader($this->select()->where($scope)->orderBy($orderBy));
15
    }
16
17
    private function findIdentityBy(string $field, string $value): ?IdentityInterface
18
    {
19
        return $this->findOne([$field => $value]);
20
    }
21
22
    public function findIdentity(string $id): ?IdentityInterface
23
    {
24
        return $this->findByPK($id);
25
    }
26
27
    public function findIdentityByToken(string $token, string $type): ?IdentityInterface
28
    {
29
        return $this->findIdentityBy('token', $token);
30
    }
31
32
    public function findByLogin(string $login): ?IdentityInterface
33
    {
34
        return $this->findIdentityBy('login', $login);
35
    }
36
}
37