AbstractProxy   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 9
c 3
b 0
f 0
dl 0
loc 59
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getUserProvider() 0 3 1
A __construct() 0 3 1
A getUsernameField() 0 3 1
A getGuard() 0 3 1
A setUsernameField() 0 5 1
1
<?php
2
3
namespace Signifly\Janitor;
4
5
use Illuminate\Contracts\Auth\UserProvider;
6
use Illuminate\Support\Facades\Auth;
7
use Signifly\Janitor\Contracts\Proxy;
8
9
abstract class AbstractProxy implements Proxy
10
{
11
    /** @var array */
12
    protected $config;
13
14
    /** @var string */
15
    protected $usernameField;
16
17
    /**
18
     * Create a new instance.
19
     *
20
     * @param array $config
21
     */
22
    public function __construct(array $config)
23
    {
24
        $this->config = $config;
25
    }
26
27
    /**
28
     * Get the guard.
29
     *
30
     * @return string
31
     */
32
    protected function getGuard()
33
    {
34
        return Auth::guard();
35
    }
36
37
    /**
38
     * Get the user instance.
39
     *
40
     * @return \Illuminate\Contracts\Auth\UserProvider
41
     */
42
    protected function getUserProvider(): UserProvider
43
    {
44
        return Auth::getProvider();
45
    }
46
47
    /**
48
     * Get username field.
49
     *
50
     * @return string
51
     */
52
    public function getUsernameField(): string
53
    {
54
        return $this->usernameField ?? config('janitor.username_field');
55
    }
56
57
    /**
58
     * Set the username field.
59
     *
60
     * @param string $username
61
     * @return $this
62
     */
63
    public function setUsernameField(string $username): self
64
    {
65
        $this->usernameField = $username;
66
67
        return $this;
68
    }
69
}
70