AuthServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 29
ccs 0
cts 11
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 6 1
A boot() 0 4 1
A configPath() 0 3 1
1
<?php
2
3
namespace Napp\Core\Api\Auth;
4
5
use Illuminate\Support\Facades\Auth;
6
use Illuminate\Support\ServiceProvider;
7
8
/**
9
 * Class AuthServiceProvider.
10
 */
11
class AuthServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * @return void
15
     */
16
    public function register()
17
    {
18
        $this->mergeConfigFrom($this->configPath(), 'api-core');
19
20
        Auth::extend('api', function ($app, $name, array $config) {
21
            return new ApiGuard(Auth::createUserProvider($config['provider']), $app['request'], $app['config']->get('api-core.api-key'));
0 ignored issues
show
Bug introduced by
It seems like Illuminate\Support\Facad...er($config['provider']) can also be of type null; however, parameter $provider of Napp\Core\Api\Auth\ApiGuard::__construct() does only seem to accept Illuminate\Contracts\Auth\UserProvider, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

21
            return new ApiGuard(/** @scrutinizer ignore-type */ Auth::createUserProvider($config['provider']), $app['request'], $app['config']->get('api-core.api-key'));
Loading history...
22
        });
23
    }
24
25
    public function boot()
26
    {
27
        $this->publishes([
28
            $this->configPath() => config_path('api-core.php'),
29
        ]);
30
    }
31
32
    /**
33
     * Get the config path.
34
     *
35
     * @return string
36
     */
37
    protected function configPath()
38
    {
39
        return __DIR__ . '/../../config/api-core.php';
40
    }
41
}
42