Passed
Pull Request — master (#49)
by Alexander
25:24 queued 10:30
created

UserRepository::__construct()   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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Repository;
4
5
use Cycle\ORM\Select;
6
use Yiisoft\Auth\IdentityInterface;
7
use Yiisoft\Auth\IdentityRepositoryInterface;
8
9
class UserRepository extends Select\Repository implements IdentityRepositoryInterface
10
{
11
    private function findIdentityBy(string $field, string $value): ?IdentityInterface
12
    {
13
        return $this->findOne([$field => $value]);
14
    }
15
16
    public function findIdentity(string $id): ?IdentityInterface
17
    {
18
        return $this->findByPK($id);
19
    }
20
21
    public function findIdentityByToken(string $token, string $type): ?IdentityInterface
22
    {
23
        return $this->findIdentityBy('token', $token);
24
    }
25
26
    public function findByLogin(string $login): ?IdentityInterface
27
    {
28
        return $this->findIdentityBy('login', $login);
29
    }
30
}
31