Completed
Pull Request — master (#10)
by
unknown
04:25
created

CacheServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
dl 0
loc 43
ccs 5
cts 10
cp 0.5
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 14 1
A provides() 0 8 1
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