Completed
Push — master ( 9d421d...7b686b )
by Avtandil
10:28 queued 08:22
created

CacheServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
dl 0
loc 43
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 3

2 Methods

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