FaviconServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 10 1
A registerRoutes() 0 4 1
A boot() 0 9 2
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