BreadcrumbsServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arcanedev\Breadcrumbs;
6
7
use Arcanedev\Breadcrumbs\Contracts\Breadcrumbs as BreadcrumbsContract;
8
use Arcanedev\Support\Providers\PackageServiceProvider;
9
use Illuminate\Contracts\Support\DeferrableProvider;
10
11
/**
12
 * Class     BreadcrumbsServiceProvider
13
 *
14
 * @author   ARCANEDEV <[email protected]>
15
 */
16
class BreadcrumbsServiceProvider extends PackageServiceProvider implements DeferrableProvider
17
{
18
    /* -----------------------------------------------------------------
19
     |  Properties
20
     | -----------------------------------------------------------------
21
     */
22
23
    /**
24
     * Package name.
25
     *
26
     * @var string
27
     */
28
    protected $package = 'breadcrumbs';
29
30
    /* -----------------------------------------------------------------
31
     |  Main Methods
32
     | -----------------------------------------------------------------
33
     */
34
35
    /**
36
     * Register the service provider.
37
     */
38 132
    public function register(): void
39
    {
40 132
        parent::register();
41
42 132
        $this->registerConfig();
43
44
        // Register the Breadcrumbs service.
45 44
        $this->singleton(BreadcrumbsContract::class, function ($app) {
46 54
            return new Breadcrumbs(
47 54
                $app['config']->get('breadcrumbs.template.supported', []),
48 54
                $app['config']->get('breadcrumbs.template.default', '')
49
            );
50 132
        });
51 132
    }
52
53
    /**
54
     * Boot the service provider.
55
     */
56 132
    public function boot(): void
57
    {
58 132
        $this->loadTranslations();
59 132
        $this->loadViews();
60
61 132
        if ($this->app->runningInConsole()) {
62 132
            $this->publishConfig();
63 132
            $this->publishTranslations();
64 132
            $this->publishViews();
65
        }
66 132
    }
67
68
    /**
69
     * Get the services provided by the provider
70
     *
71
     * @return array
72
     */
73 4
    public function provides(): array
74
    {
75
        return [
76 4
            BreadcrumbsContract::class,
77
        ];
78
    }
79
}
80