CoverCacheServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Colligator\Providers;
4
5
use Colligator\CoverCache;
6
use Http\Client\HttpClient;
7
use Http\Message\MessageFactory;
8
use Illuminate\Support\ServiceProvider;
9
use Intervention\Image\ImageManager;
10
use League\Flysystem\Config as FlysystemConfig;
11
12
class CoverCacheServiceProvider extends ServiceProvider
13
{
14
	/**
15
     * Indicates if loading of the provider is deferred.
16
     *
17
     * @var bool
18
     */
19
    protected $defer = true;
20
21
    /**
22
     * Register the service provider.
23
     *
24
     * @return void
25
     */
26
    public function register()
27
    {
28
        $this->app->singleton(CoverCache::class, function () {
29
            $fs = \Storage::disk('s3')->getAdapter();
0 ignored issues
show
Bug introduced by
The method getAdapter() does not seem to exist on object<Illuminate\Contra...\Filesystem\Filesystem>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
            $im = $this->app->make(ImageManager::class);
31
            $conf = new FlysystemConfig([
32
                // Default: 30 days
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
                'CacheControl' => 'max-age=' . env('IMAGE_CACHE_TIME', 3153600) . ', public',
34
            ]);
35
            $http = $this->app->make(HttpClient::class);
36
            $messageFactory = $this->app->make(MessageFactory::class);
37
            return new CoverCache($fs, $im, $conf, $http, $messageFactory);
38
        });
39
    }
40
41
    /**
42
     * Get the services provided by the provider.
43
     *
44
     * @return array
45
     */
46
    public function provides()
47
    {
48
        return [CoverCache::class];
49
    }
50
}
51