Completed
Push — master ( 89e5ef...e6c644 )
by ARCANEDEV
18:24
created

BreadcrumbsServiceProvider::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
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php namespace Arcanedev\Breadcrumbs;
2
3
use Arcanedev\Support\PackageServiceProvider;
4
5
/**
6
 * Class     BreadcrumbsServiceProvider
7
 *
8
 * @package  Arcanedev\Breadcrumbs
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class BreadcrumbsServiceProvider extends PackageServiceProvider
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Package name.
19
     *
20
     * @var string
21
     */
22
    protected $package = 'breadcrumbs';
23
24
    /**
25
     * Indicates if loading of the provider is deferred.
26
     *
27
     * @var bool
28
     */
29
    protected $defer   = true;
30
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Getters & Setters
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    /**
36
     * Get the base path of the package.
37
     *
38
     * @return string
39
     */
40 276
    public function getBasePath()
41
    {
42 276
        return dirname(__DIR__);
43
    }
44
45
    /* ------------------------------------------------------------------------------------------------
46
     |  Main Functions
47
     | ------------------------------------------------------------------------------------------------
48
     */
49
    /**
50
     * Register the service provider.
51
     */
52 276
    public function register()
53
    {
54 276
        $this->registerConfig();
55 276
        $this->registerBreadcrumbsService();
56 276
    }
57
58
    /**
59
     * Boot the service provider.
60
     */
61 276
    public function boot()
62
    {
63 276
        parent::boot();
64
65
        // Publishes
66 276
        $this->publishConfig();
67 276
        $this->publishViews();
68 276
    }
69
70
    /**
71
     * Get the services provided by the provider
72
     *
73
     * @return array
74
     */
75 24
    public function provides()
76
    {
77
        return [
78 24
            'arcanedev.breadcrumbs',
79 8
            Contracts\Breadcrumbs::class,
80 8
        ];
81
    }
82
83
    /* ------------------------------------------------------------------------------------------------
84
     |  Other Functions
85
     | ------------------------------------------------------------------------------------------------
86
     */
87
    /**
88
     * Register the Breadcrumbs service.
89
     */
90
    private function registerBreadcrumbsService()
91
    {
92 276
        $this->singleton(Contracts\Breadcrumbs::class, function ($app) {
93
            /** @var  \Illuminate\Contracts\Config\Repository  $config */
94 120
            $config = $app['config'];
95
96 120
            return new Breadcrumbs(
97 120
                $config->get('breadcrumbs.template.supported', []),
98 120
                $config->get('breadcrumbs.template.default', '')
99 40
            );
100 276
        });
101
102 276
        $this->singleton('arcanedev.breadcrumbs', Contracts\Breadcrumbs::class);
103 276
    }
104
}
105