Completed
Pull Request — master (#4)
by Evgenii
02:07
created

ImgixServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 36
rs 10
c 2
b 0
f 0
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 1
A register() 0 18 1
1
<?php
2
3
namespace Nasyrov\Laravel\Imgix;
4
5
use Illuminate\Support\ServiceProvider;
6
use Imgix\ShardStrategy;
7
use Imgix\UrlBuilder;
8
9
class ImgixServiceProvider extends ServiceProvider
10
{
11
    const ALIAS = 'imgix';
12
13
    /**
14
     * Bootstrap any application services.
15
     */
16
    public function boot()
17
    {
18
        $this->publishes([
19
            dirname(__DIR__) . '/config/imgix.php' => config_path('imgix.php'),
20
        ], 'imgix');
21
    }
22
23
    /**
24
     * Register any application services.
25
     */
26
    public function register()
27
    {
28
        $this->app->singleton(UrlBuilder::class, function () {
29
            return new UrlBuilder(
30
                config('imgix.domains', []),
31
                config('imgix.useHttps', false),
32
                config('imgix.signKey', ''),
33
                config('imgix.shardStrategy', ShardStrategy::CRC),
34
                config('imgix.includeLibraryParam', true)
35
            );
36
        });
37
38
        $this->app->singleton(Imgix::class, function ($app) {
39
            return new Imgix($app[UrlBuilder::class]);
40
        });
41
42
        $this->app->alias(Imgix::class, static::ALIAS);
43
    }
44
}
45