Completed
Push — master ( b55765...9326ca )
by Evgenii
13s
created

ImgixServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 1
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 9
    public function boot()
17
    {
18 9
        $configFile = dirname(__DIR__) . '/config/imgix.php';
19
20 9
        $this->mergeConfigFrom($configFile, static::ALIAS);
21
22 9
        $this->publishes([
23 9
            $configFile => config_path('imgix.php'),
24 9
        ], static::ALIAS);
25 9
    }
26
27
    /**
28
     * Register any application services.
29
     */
30 9
    public function register()
31
    {
32
        $this->app->singleton(UrlBuilder::class, function () {
33 6
            return new UrlBuilder(
34 6
                config('imgix.domains'),
35 6
                config('imgix.useHttps', false),
36 6
                config('imgix.signKey', ''),
37 6
                config('imgix.shardStrategy', ShardStrategy::CRC),
38 6
                config('imgix.includeLibraryParam', true)
39 2
            );
40 9
        });
41
42 9
        $this->app->singleton(Imgix::class, function ($app) {
43 6
            return new Imgix($app[UrlBuilder::class]);
44 9
        });
45
46 9
        $this->app->alias(Imgix::class, static::ALIAS);
47 9
    }
48
}
49