FaviconServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace BeyondCode\LaravelFavicon;
4
5
use BeyondCode\LaravelFavicon\Generators\FaviconGenerator;
6
use BeyondCode\LaravelFavicon\Http\Controllers\FaviconController;
7
use Illuminate\Support\Facades\Route;
8
use Illuminate\Support\ServiceProvider;
9
10
class FaviconServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap the application services.
14
     */
15
    public function boot()
16
    {
17
        if ($this->app->runningInConsole()) {
18
            $this->publishes([
19
                __DIR__.'/../config/favicon.php' => config_path('favicon.php'),
20
            ], 'config');
21
        }
22
23
        $this->registerRoutes();
24
    }
25
26
    /**
27
     * Register the application services.
28
     */
29
    public function register()
30
    {
31
        $this->mergeConfigFrom(__DIR__.'/../config/favicon.php', 'favicon');
32
33
        $this->app->singleton(Favicon::class, function () {
34
            return new Favicon(config('favicon'));
35
        });
36
37
        $this->app->bind(FaviconGenerator::class, function () {
38
            return app(config('favicon.generator'));
39
        });
40
    }
41
42
    protected function registerRoutes()
43
    {
44
        Route::get(config('favicon.url_prefix').'/{icon}', FaviconController::class)
45
            ->where('icon', '.*');
46
    }
47
}
48