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

BreadcrumbsServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 94
rs 10
c 2
b 0
f 0
ccs 24
cts 24
cp 1
wmc 5
lcom 1
cbo 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getBasePath() 0 4 1
A register() 0 5 1
A boot() 0 8 1
A provides() 0 7 1
A registerBreadcrumbsService() 0 14 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