AuthServiceProvider::configPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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