Completed
Push — master ( 9c3153...125483 )
by Avtandil
16s queued 14s
created

CacheServiceProvider::provides()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 8
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Longman\LaravelLodash\Cache;
6
7
use Illuminate\Cache\MemcachedConnector;
8
use Illuminate\Support\ServiceProvider;
9
10
class CacheServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Indicates if loading of the provider is deferred.
14
     *
15
     * @var bool
16
     */
17
    protected $defer = true;
18
19
    /**
20
     * Register the service provider.
21
     *
22
     * @return void
23
     */
24 15
    public function register(): void
25
    {
26
        $this->app->singleton('cache', static function ($app) {
27
            return new CacheManager($app);
28 15
        });
29
30
        $this->app->singleton('cache.store', static function ($app) {
31
            return $app['cache']->driver();
32 15
        });
33
34
        $this->app->singleton('memcached.connector', static function () {
35
            return new MemcachedConnector();
36 15
        });
37 15
    }
38
39
    /**
40
     * Get the services provided by the provider.
41
     *
42
     * @return array
43
     */
44
    public function provides()
45
    {
46
        return [
47
            'cache',
48
            'cache.store',
49
            'memcached.connector',
50
        ];
51
    }
52
}
53