Passed
Pull Request — master (#660)
by butschster
07:38
created

WebsocketsBootloader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 11
ccs 0
cts 3
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A start() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Broadcasting\Bootloader;
6
7
use Spiral\Boot\Bootloader\Bootloader;
8
use Spiral\Bootloader\Http\HttpBootloader;
9
use Spiral\Broadcasting\Config\BroadcastConfig;
10
use Spiral\Broadcasting\Driver\AuthorizationMiddleware;
11
use Spiral\Core\Container\SingletonInterface;
12
13
final class WebsocketsBootloader extends Bootloader implements SingletonInterface
14
{
15
    protected const DEPENDENCIES = [
16
        HttpBootloader::class,
17
        BroadcastingBootloader::class,
18
    ];
19
20
    public function start(HttpBootloader $http, BroadcastConfig $config): void
21
    {
22
        if ($config->getAuthorizationPath() !== null) {
23
            $http->addMiddleware(AuthorizationMiddleware::class);
24
        }
25
    }
26
}
27