Passed
Push — develop ( 53798b...20a922 )
by Enea
02:15
created

AuthorizationServiceProvider::configDriver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Created on 12/02/18 by enea dhack.
6
 */
7
8
namespace Enea\Authorization;
9
10
use Enea\Authorization\Commands\InstallCommand;
11
use Enea\Authorization\Contracts\PermissionContract;
12
use Enea\Authorization\Contracts\RoleContract;
13
use Enea\Authorization\Support\Config;
14
use Illuminate\Support\ServiceProvider;
15
16
class AuthorizationServiceProvider extends ServiceProvider
17
{
18
    /**
19
     * Bootstrap the application services.
20
     *
21
     * @return void
22
     */
23 49
    public function boot(): void
24
    {
25 49
        $this->publish();
26 49
    }
27
28
    /**
29
     * Register the application services.
30
     *
31
     * @return void
32
     */
33 49
    public function register(): void
34
    {
35 49
        $this->app->register(EventServiceProvider::class);
36
37 49
        $this->commands([
38 49
            InstallCommand::class
39
        ]);
40
41 49
        $this->registerBindings();
42 49
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function provides()
48
    {
49
        return [
50
            Authorizer::class,
51
        ];
52
    }
53
54 49
    private function publish(): void
55
    {
56 49
        $this->publishes([
57 49
            __DIR__ . '/../config/authorization.php' => base_path('config/authorization.php')
58
        ]);
59 49
    }
60
61 49
    private function registerBindings(): void
62
    {
63 49
        $this->configDriver();
64 49
        $this->app->bind(PermissionContract::class, Config::permissionModel());
65 49
        $this->app->bind(RoleContract::class, Config::roleModel());
66 49
    }
67
68 49
    private function configDriver(): void
69
    {
70 49
        (new DriversResolver($this->app))->make();
71 49
    }
72
}
73