ServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 11 1
A boot() 0 2 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: hugh.li
5
 * Date: 2021/4/18
6
 * Time: 10:32 下午.
7
 */
8
9
namespace HughCube\Laravel\Auth;
10
11
use Illuminate\Auth\AuthManager;
12
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
13
14
class ServiceProvider extends IlluminateServiceProvider
15
{
16
    /**
17
     * Boot the provider.
18
     */
19
    public function boot()
20
    {
21
    }
22
23
    /**
24
     * Register the provider.
25
     */
26
    public function register()
27
    {
28
        $this->app->resolving('auth', function ($auth) {
29
            /** @var AuthManager $auth */
30
            $auth->provider('cache', function ($app, $config) {
31
                return new CacheProvider(
32
                    ($config['hash'] ?? $app['hash']),
33
                    ($config['cache'] ?? $app->config->get('cache.default')),
34
                    ($config['expiresInSeconds'] ?? (7 * 24 * 3600)),
35
                    ($config['cacheKeyPrefix'] ?? 'auth'),
36
                    ($config['cacheTags'] ?? [])
37
                );
38
            });
39
        });
40
    }
41
}
42