DummyUserProvider   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 50
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A retrieveById() 0 6 2
A retrieveByToken() 0 4 1
A updateRememberToken() 0 4 1
A retrieveByCredentials() 0 4 1
A validateCredentials() 0 4 1
1
<?php
2
3
namespace Longman\LaravelDummyUser;
4
5
use Illuminate\Contracts\Auth\Authenticatable;
6
use Illuminate\Contracts\Auth\UserProvider as LaravelUserProvider;
7
use Illuminate\Contracts\Cache\Repository as CacheContract;
8
use RuntimeException;
9
10
class DummyUserProvider implements LaravelUserProvider
11
{
12
    /**
13
     * Application cache repository.
14
     *
15
     * @var \Illuminate\Contracts\Cache\Repository
16
     */
17
    protected $cache;
18
19
    /**
20
     * Configuration.
21
     *
22
     * @var array
23
     */
24
    protected $config;
25
26
    public function __construct(CacheContract $cache, array $config)
27
    {
28
        $this->cache = $cache;
29
        $this->config = $config;
30
    }
31
32
    public function retrieveById($identifier)
33
    {
34
        $user = $this->cache->get('users.' . $identifier);
35
36
        return $user instanceof Authenticatable ? $user : null;
37
    }
38
39
    public function retrieveByToken($identifier, $token)
40
    {
41
        // Not implemented yet
42
    }
43
44
    public function updateRememberToken(Authenticatable $user, $token)
45
    {
46
        // Not implemented yet
47
    }
48
49
    public function retrieveByCredentials(array $credentials)
50
    {
51
        throw new RuntimeException('Not implemented yet');
52
    }
53
54
    public function validateCredentials(Authenticatable $user, array $credentials)
55
    {
56
        throw new RuntimeException('Not implemented yet');
57
    }
58
59
}
60