Completed
Push — develop ( 2e7b9b...10ff7a )
by Enea
05:13
created

AuthorizationServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 90.48%

Importance

Changes 0
Metric Value
dl 0
loc 51
ccs 19
cts 21
cp 0.9048
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 3 1
A register() 0 4 1
A registerBindings() 0 5 1
A provides() 0 4 1
A configDriver() 0 3 1
A publish() 0 5 1
1
<?php
2
/**
3
 * Created on 12/02/18 by enea dhack.
4
 */
5
6
namespace Enea\Authorization;
7
8
use Enea\Authorization\Contracts\PermissionContract;
9
use Enea\Authorization\Contracts\RoleContract;
10
use Enea\Authorization\Support\Config;
11
use Illuminate\Support\ServiceProvider;
12
13
class AuthorizationServiceProvider extends ServiceProvider
14
{
15
    /**
16
     * Bootstrap the application services.
17
     *
18
     * @return void
19
     */
20 47
    public function boot(): void
21
    {
22 47
        $this->publish();
23 47
    }
24
25
    /**
26
     * Register the application services.
27
     *
28
     * @return void
29
     */
30 47
    public function register(): void
31
    {
32 47
        $this->app->register(EventServiceProvider::class);
33 47
        $this->registerBindings();
34 47
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function provides()
40
    {
41
        return [
42
            Authorizer::class,
43
        ];
44
    }
45
46 47
    private function publish(): void
47
    {
48 47
        $this->publishes([
49 47
            __DIR__ . "/../database/migrations" => database_path('migrations'),
50 47
            __DIR__ . "/../config/authorization.php" => base_path('config/authorization.php')
51
        ]);
52 47
    }
53
54 47
    private function registerBindings(): void
55
    {
56 47
        $this->configDriver();
57 47
        $this->app->bind(PermissionContract::class, Config::permissionModel());
58 47
        $this->app->bind(RoleContract::class, Config::roleModel());
59 47
    }
60
61 47
    private function configDriver(): void
62
    {
63 47
        (new DriversResolver($this->app))->make();
64 47
    }
65
}
66