Completed
Pull Request — master (#447)
by Alexandru
01:20
created

PushesToPusher::getPusherBroadcaster()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace BeyondCode\LaravelWebSockets\Contracts;
4
5
use BeyondCode\LaravelWebSockets\PubSub\Broadcasters\RedisPusherBroadcaster;
6
use Illuminate\Broadcasting\Broadcasters\PusherBroadcaster;
7
use Pusher\Pusher;
8
9
trait PushesToPusher
10
{
11
    /**
12
     * Get the right Pusher broadcaster for the used driver.
13
     *
14
     * @param  array  $app
15
     * @return \Illuminate\Broadcasting\Broadcasters\Broadcaster
16
     */
17
    public function getPusherBroadcaster(array $app)
18
    {
19
        if (config('websockets.replication.driver') === 'redis') {
20
            return new RedisPusherBroadcaster(
21
                new Pusher($app['key'], $app['secret'], $app['id'], config('broadcasting.connections.websockets.options', [])),
22
                $app['id'],
23
                app('redis')
24
            );
25
        }
26
27
        return new PusherBroadcaster(
28
            new Pusher($app['key'], $app['secret'], $app['id'], config('broadcasting.connections.pusher.options', []))
29
        );
30
    }
31
}
32