UserRepository::model()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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