Completed
Push — master ( b76cb7...b55765 )
by Evgenii
14s
created

ImgixServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 10 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
        $configFile = dirname(__DIR__) . '/config/imgix.php';
19
20
        $this->mergeConfigFrom($configFile, static::ALIAS);
21
22
        $this->publishes([
23
            $configFile => config_path('imgix.php'),
24
        ], static::ALIAS);
25
    }
26
27
    /**
28
     * Register any application services.
29
     */
30
    public function register()
31
    {
32
        $this->app->singleton(UrlBuilder::class, function () {
33
            return new UrlBuilder(
34
                config('imgix.domains'),
35
                config('imgix.useHttps', false),
36
                config('imgix.signKey', ''),
37
                config('imgix.shardStrategy', ShardStrategy::CRC),
38
                config('imgix.includeLibraryParam', true)
39
            );
40
        });
41
42
        $this->app->singleton(Imgix::class, function ($app) {
43
            return new Imgix($app[UrlBuilder::class]);
44
        });
45
46
        $this->app->alias(Imgix::class, static::ALIAS);
47
    }
48
}
49