UserRepository   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 28
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A model() 0 4 1
A getUserEntityByUserCredentials() 0 19 4
1
<?php
2
3
4
namespace Mvdstam\Oauth2ServerLaravel\Repositories;
5
6
7
use Illuminate\Support\Facades\Hash;
8
use League\OAuth2\Server\Entities\ClientEntityInterface;
9
use League\OAuth2\Server\Entities\UserEntityInterface;
10
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
11
12
class UserRepository extends AbstractRepository implements UserRepositoryInterface
13
{
14 16
    public function model()
15
    {
16 16
        return UserEntityInterface::class;
17
    }
18
19 4
    public function getUserEntityByUserCredentials(
20
        $username,
21
        $password,
22
        $grantType,
23
        ClientEntityInterface $clientEntity
24
    )
25
    {
26 4
        $user = $this->findWhere([['username', '=', $username]]);
27
28 4
        if (!$user || !($user = $user->first())) {
29
            return null;
30
        }
31
32 4
        if (!Hash::check($password, $user->password)) {
33
            return null;
34
        }
35
36 4
        return $user;
37
    }
38
39
}
40