Completed
Push — master ( efafaa...1ce8a3 )
by Avtandil
05:26
created

CacheServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 64.29%

Importance

Changes 0
Metric Value
dl 0
loc 46
ccs 9
cts 14
cp 0.6429
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4

2 Methods

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