Completed
Push — develop ( a86374...2e7b9b )
by Enea
02:33
created

AuthorizationServiceProvider::publish()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
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()
21
    {
22 47
        $this->registerBindings();
23 47
    }
24
25
    /**
26
     * Register the application services.
27
     *
28
     * @return void
29
     */
30 47
    public function register()
31
    {
32 47
        $this->app->register(EventServiceProvider::class);
33 47
        $this->publish();
34 47
    }
35
36
    /**
37
     * Bind contracts with concrete objects.
38
     *
39
     * @return void
40
     */
41 47
    protected function registerBindings()
42
    {
43 47
        $this->configDriver();
44 47
        $this->app->bind(PermissionContract::class, Config::permissionModel());
45 47
        $this->app->bind(RoleContract::class, Config::roleModel());
46 47
    }
47
48 47
    private function publish(): void
49
    {
50 47
        $this->mergeConfigFrom($this->path('config/authorization.php'), 'authorization');
51 47
        $this->publishes([$this->path('database/migrations/CreateLaravelAuthorizationTables.php') => database_path('migrations')]);
52 47
    }
53
54 47
    private function path(string $path): string
55
    {
56 47
        return __DIR__ . "/../{$path}";
57
    }
58
59 47
    private function configDriver(): void
60
    {
61 47
        (new DriversResolver($this->app))->make();
62 47
    }
63
}
64