Completed
Pull Request — master (#4)
by Evgenii
01:58
created

ImgixServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 6
cp 0
crap 2
rs 9.4285
c 1
b 0
f 0
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