Passed
Push — master ( 072ff8...25b1fb )
by Morten Poul
02:11
created

AbstractProxy   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 61
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

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