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

UserRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 5
c 4
b 0
f 0
dl 0
loc 20
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A findByLogin() 0 3 1
A findIdentityByToken() 0 3 1
A findIdentityBy() 0 3 1
A findIdentity() 0 3 1
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