LaracentServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A register() 0 11 1
1
<?php
2
3
namespace AlexHnydiuk\Laracent;
4
5
use GuzzleHttp\Client as HttpClient;
6
use Illuminate\Support\ServiceProvider;
7
use Illuminate\Broadcasting\BroadcastManager;
8
9
class LaracentServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Add centrifugo broadcaster.
13
     *
14
     * @param \Illuminate\Broadcasting\BroadcastManager $broadcastManager
15
     */
16
    public function boot(BroadcastManager $broadcastManager)
17
    {
18
        $broadcastManager->extend('centrifugo', function ($app) {
19
            return new LaracentBroadcaster($app->make('centrifugo'));
20
        });
21
    }
22
23
    /**
24
     * Register the service provider.
25
     *
26
     * @return void
27
     */
28
    public function register()
29
    {
30
        $this->app->singleton('centrifugo', function ($app) {
31
            $config = $app->make('config')->get('broadcasting.connections.centrifugo');
32
            $http = new HttpClient();
33
34
            return new Laracent($config, $http);
35
        });
36
37
        $this->app->alias('centrifugo', 'AlexHnydiuk\Laracent\Laracent');
38
        $this->app->alias('centrifugo', 'AlexHnydiuk\Laracent\Contracts\Centrifugo');
39
    }
40
}
41