RedisSentinelServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace RedisSentinel\Laravel;
4
5
use Illuminate\Queue\QueueManager;
6
use Illuminate\Support\ServiceProvider;
7
8
class RedisSentinelServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Add the connector to the queue drivers
12
     */
13
    public function boot()
14
    {
15
        $this->registerRedisSentinelConnector($this->app['queue']);
16
    }
17
18
    /**
19
     * Register the service provider.
20
     *
21
     * @return void
22
     */
23
    public function register()
24
    {
25
        $this->app->singleton('redis', function($app) {
26
            return new Database($app['config']['database.redis']);
27
        });
28
    }
29
30
    protected function registerRedisSentinelConnector(QueueManager $manager)
31
    {
32
        $manager->addConnector('sentinel-redis', function() {
33
            return new SentinelConnector($this->app['redis']);
34
        });
35
    }
36
37
    /**
38
     * Get the services provided by the provider.
39
     *
40
     * @return array
41
     */
42
    public function provides()
43
    {
44
        return ['redis'];
45
    }
46
}
47