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

CacheServiceProvider::provides()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 8
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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