Passed
Pull Request — master (#653)
by Aleksei
05:48
created

WSBootloader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 4
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\App\Bootloader;
13
14
use Spiral\Boot\Bootloader\Bootloader;
15
use Spiral\Boot\EnvironmentInterface;
16
use Spiral\Bootloader\Http\WebsocketsBootloader;
17
18
class WSBootloader extends Bootloader
19
{
20
    protected const DEPENDENCIES = [WebsocketsBootloader::class];
21
22
    public function boot(WebsocketsBootloader $ws, EnvironmentInterface $env): void
23
    {
24
        if ($env->get('RR_BROADCAST_PATH') === null) {
25
            return;
26
        }
27
28
        $ws->authorizeServer($env->get('WS_SERVER_CALLBACK'));
29
30
        if ($env->get('WS_TOPIC_CALLBACK') !== null) {
31
            $ws->authorizeTopic('topic', $env->get('WS_TOPIC_CALLBACK'));
32
        }
33
34
        if ($env->get('WS_TOPIC_WILDCARD_CALLBACK') !== null) {
35
            $ws->authorizeTopic('wildcard.{id}', $env->get('WS_TOPIC_WILDCARD_CALLBACK'));
36
        }
37
    }
38
}
39