Completed
Push — master ( bdd757...e0683b )
by ARCANEDEV
11:00
created

LaravelAuthServiceProvider::getBasePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\LaravelAuth;
2
3
use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
4
use Arcanesoft\Contracts\Auth\Models as AuthContracts;
5
6
/**
7
 * Class     LaravelAuthServiceProvider
8
 *
9
 * @package  Arcanedev\LaravelAuth
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class LaravelAuthServiceProvider extends ServiceProvider
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * Package name.
20
     *
21
     * @var string
22
     */
23
    protected $package = 'laravel-auth';
24
25
    /* ------------------------------------------------------------------------------------------------
26
     |  Getters & Setters
27
     | ------------------------------------------------------------------------------------------------
28
     */
29
    /**
30
     * Get the base path of the package.
31
     *
32
     * @return string
33
     */
34 612
    public function getBasePath()
35
    {
36 612
        return dirname(__DIR__);
37
    }
38
39
    /* ------------------------------------------------------------------------------------------------
40
     |  Main Functions
41
     | ------------------------------------------------------------------------------------------------
42
     */
43
    /**
44
     * Register the service provider.
45
     */
46 612
    public function register()
47
    {
48 612
        $this->registerConfig();
49 612
        $this->bindModels();
50
51 612
        if ($this->config()->get('laravel-auth.use-observers', false)) {
52 612
            $this->app->register(Providers\EventServiceProvider::class);
53 204
        }
54 612
    }
55
56
    /**
57
     * Boot the service provider.
58
     */
59 612
    public function boot()
60
    {
61 612
        parent::boot();
62
63 612
        $this->publishConfig();
64 612
        $this->publishMigrations();
65 612
        $this->publishFactories();
66 612
    }
67
68
    /**
69
     * Get the services provided by the provider.
70
     *
71
     * @return array
72
     */
73 9
    public function provides()
74
    {
75
        return [
76
            //
77 9
        ];
78
    }
79
80
    /* ------------------------------------------------------------------------------------------------
81
     |  Other Functions
82
     | ------------------------------------------------------------------------------------------------
83
     */
84
    /**
85
     * Binding the models with the contracts.
86
     */
87 612
    private function bindModels()
88
    {
89
        $bindings = [
90 612
            'users'              => AuthContracts\User::class,
91 204
            'roles'              => AuthContracts\Role::class,
92 204
            'permissions'        => AuthContracts\Permission::class,
93 204
            'permissions-groups' => AuthContracts\PermissionsGroup::class,
94 204
        ];
95
96 612
        foreach ($bindings as $key => $contract) {
97 612
            $this->bind($contract, $this->config()->get("laravel-auth.$key.model"));
98 204
        }
99 612
    }
100
}
101