Completed
Pull Request — master (#5)
by Evgenii
01:59
created

ImgixServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

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

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 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