Completed
Pull Request — master (#9)
by ARCANEDEV
06:36
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
    /**
19
     * Package name.
20
     *
21
     * @var string
22
     */
23
    protected $package = 'breadcrumbs';
24
25
    /**
26
     * Indicates if loading of the provider is deferred.
27
     *
28
     * @var bool
29
     */
30
    protected $defer   = true;
31
32
    /* -----------------------------------------------------------------
33
     |  Main Methods
34
     | -----------------------------------------------------------------
35
     */
36
37
    /**
38
     * Register the service provider.
39
     */
40 69
    public function register()
41
    {
42 69
        parent::register();
43
44 69
        $this->registerConfig();
45 69
        $this->registerBreadcrumbsService();
46 69
    }
47
48
    /**
49
     * Boot the service provider.
50
     */
51 69
    public function boot()
52
    {
53 69
        parent::boot();
54
55
        // Publishes
56 69
        $this->publishConfig();
57 69
        $this->publishViews();
58 69
        $this->publishTranslations();
59 69
    }
60
61
    /**
62
     * Get the services provided by the provider
63
     *
64
     * @return array
65
     */
66 6
    public function provides()
67
    {
68
        return [
69 6
            Contracts\Breadcrumbs::class,
70 2
        ];
71
    }
72
73
    /* -----------------------------------------------------------------
74
     |  Other Methods
75
     | -----------------------------------------------------------------
76
     */
77
78
    /**
79
     * Register the Breadcrumbs service.
80
     */
81
    private function registerBreadcrumbsService()
82
    {
83 69
        $this->singleton(Contracts\Breadcrumbs::class, function ($app) {
84
            /** @var  \Illuminate\Contracts\Config\Repository  $config */
85 30
            $config = $app['config'];
86
87 30
            return new Breadcrumbs(
88 30
                $config->get('breadcrumbs.template.supported', []),
89 30
                $config->get('breadcrumbs.template.default', '')
90 10
            );
91 69
        });
92 23
    }
93
}
94