Completed
Push — 5.3 ( 3c79db...4ca8c4 )
by Arjay
01:40 queued 01:35
created

OracleUserProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A retrieveByCredentials() 0 19 4
1
<?php
2
3
namespace Yajra\Oci8\Auth;
4
5
use Illuminate\Auth\EloquentUserProvider;
6
use Illuminate\Support\Str;
7
8
class OracleUserProvider extends EloquentUserProvider
9
{
10
    /**
11
     * Retrieve a user by the given credentials.
12
     *
13
     * @param  array $credentials
14
     * @return \Illuminate\Contracts\Auth\Authenticatable|null
15
     */
16
    public function retrieveByCredentials(array $credentials)
17
    {
18
        if (empty($credentials)) {
19
            return;
20
        }
21
22
        // First we will add each credential element to the query as a where clause.
23
        // Then we can execute the query and, if we found a user, return it in a
24
        // Eloquent User "model" that will be utilized by the Guard instances.
25
        $query = $this->createModel()->newQuery();
26
27
        foreach ($credentials as $key => $value) {
28
            if (! Str::contains($key, 'password')) {
29
                $query->whereRaw("upper({$key}) = upper(?)", [$value]);
30
            }
31
        }
32
33
        return $query->first();
34
    }
35
}
36