Completed
Push — api/develop ( 67b89b...086d67 )
by Bertrand
11:33 queued 57s
created

OAuthServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 34
ccs 10
cts 12
cp 0.8333
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 16 1
A register() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the HRis Software package.
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * Licensed under the 3-clause BSD License.
9
 *
10
 * This source file is subject to the 3-clause BSD License that is
11
 * bundled with this package in the LICENSE file.
12
 *
13
 * @version    alpha
14
 *
15
 * @author     Bertrand Kintanar <[email protected]>
16
 * @license    BSD License (3-clause)
17
 * @copyright  (c) 2014-2016, b8 Studios, Ltd
18
 *
19
 * @link       http://github.com/HB-Co/HRis
20
 */
21
22
namespace HRis\Providers;
23
24
use Dingo\Api\Auth\Auth;
25
use Dingo\Api\Auth\Provider\OAuth2;
26
use Illuminate\Support\ServiceProvider;
27
use Irradiate\Eloquent\User;
28
29
class OAuthServiceProvider extends ServiceProvider
30
{
31
    /**
32
     * Bootstrap any application services.
33
     *
34
     * @return void
35
     */
36 204
    public function boot()
37
    {
38
        $this->app[Auth::class]->extend('oauth', function ($app) {
39 204
            $provider = new OAuth2($app['oauth2-server.authorizer']->getChecker());
40
41
            $provider->setUserResolver(function ($id) {
42
                return User::findOrFail($id);
43 204
            });
44
45 204
            $provider->setClientResolver(function ($id) {
46
                return User::findOrFail($id);
47 204
            });
48
49 204
            return $provider;
50 204
        });
51 204
    }
52
53
    /**
54
     * Register any application services.
55
     *
56
     * @return void
57
     */
58 204
    public function register()
59
    {
60
        //
61 204
    }
62
}
63