ApiServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Yeelight\Providers;
4
5
use Illuminate\Auth\Access\AuthorizationException;
6
use Illuminate\Auth\AuthenticationException;
7
use Illuminate\Support\ServiceProvider;
8
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
9
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
10
11
/**
12
 * Class ApiServiceProvider
13
 *
14
 * @category Yeelight
15
 *
16
 * @package Yeelight\Providers
17
 *
18
 * @author Sheldon Lee <[email protected]>
19
 *
20
 * @license https://opensource.org/licenses/MIT MIT
21
 *
22
 * @link https://www.yeelight.com
23
 */
24
class ApiServiceProvider extends ServiceProvider
25
{
26
    /**
27
     * Bootstrap the application services.
28
     *
29
     * @return void
30
     */
31
    public function boot()
32
    {
33
        $handler = app('Dingo\Api\Exception\Handler');
34
        $handler->register(function (AuthenticationException $exception) {
35
            throw new UnauthorizedHttpException(null, $exception->getMessage());
36
        });
37
        $handler->register(function (AuthorizationException $exception) {
38
            throw new AccessDeniedHttpException($exception->getMessage());
39
        });
40
    }
41
42
    /**
43
     * Register the application services.
44
     *
45
     * @return void
46
     */
47
    public function register()
48
    {
49
        //
50
    }
51
}
52