ImgixServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 1
rs 9.9332
c 0
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.domain'),
35 6
                config('imgix.useHttps', false),
36 6
                config('imgix.signKey', ''),
37 6
                config('imgix.includeLibraryParam', true)
38
            );
39 9
        });
40
41
        $this->app->singleton(Imgix::class, function ($app) {
42 6
            return new Imgix($app[ UrlBuilder::class ]);
43 9
        });
44
45 9
        $this->app->alias(Imgix::class, static::ALIAS);
46 9
    }
47
}
48