Passed
Push — master ( ecbb01...bd6415 )
by Albert
04:49 queued 02:14
created

LumenServiceProvider::bootWebsocketRoutes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SwooleTW\Http;
4
5
use SwooleTW\Http\Server\Manager;
6
use SwooleTW\Http\Middleware\AccessLog;
7
8
/**
9
 * @codeCoverageIgnore
10
 */
11
class LumenServiceProvider extends HttpServiceProvider
12
{
13
    /**
14
     * Register manager.
15
     *
16
     * @return void
17
     */
18
    protected function registerManager()
19
    {
20
        $this->app->singleton(Manager::class, function ($app) {
21
            return new Manager($app, 'lumen');
22
        });
23
24
        $this->app->alias(Manager::class, 'swoole.manager');
25
    }
26
27
    /**
28
     * Boot websocket routes.
29
     *
30
     * @return void
31
     */
32
    protected function bootWebsocketRoutes()
33
    {
34
        $app = $this->app;
35
36
        // router only exists after lumen 5.5
37
        if (property_exists($app, 'router')) {
38
            $app->router->group(['namespace' => 'SwooleTW\Http\Controllers'], function ($app) {
39
                require __DIR__ . '/../routes/lumen_routes.php';
40
            });
41
        } else {
42
            $app->group(['namespace' => 'App\Http\Controllers'], function ($app) {
0 ignored issues
show
Bug introduced by
The method group() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
            $app->/** @scrutinizer ignore-call */ 
43
                  group(['namespace' => 'App\Http\Controllers'], function ($app) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
                require __DIR__ . '/../routes/lumen_routes.php';
44
            });
45
        }
46
    }
47
48
    /**
49
     * Register access log middleware to container.
50
     *
51
     * @return void
52
     */
53
    protected function pushAccessLogMiddleware()
54
    {
55
        $this->app->middleware(AccessLog::class);
0 ignored issues
show
Bug introduced by
SwooleTW\Http\Middleware\AccessLog::class of type string is incompatible with the type Closure|array expected by parameter $middleware of Laravel\Lumen\Application::middleware(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

55
        $this->app->middleware(/** @scrutinizer ignore-type */ AccessLog::class);
Loading history...
56
    }
57
}
58