Passed
Push — master ( f55dd4...6ac744 )
by Mohammad
13:39 queued 20s
created

WebSocketService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 46
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 14 1
1
<?php
2
3
namespace Shamaseen\Laravel\Ratchet\Commands;
4
5
use Shamaseen\Laravel\Ratchet\Receiver;
6
use Illuminate\Console\Command;
7
use Ratchet\Http\HttpServer;
8
use Ratchet\Server\IoServer;
9
use Ratchet\WebSocket\WsServer;
10
11
12
/**
13
 * Class ChatService
14
 * @package App\Console\Commands
15
 */
16
class WebSocketService extends Command
17
{
18
    /**
19
     * The name and signature of the console command.
20
     *
21
     * @var string
22
     */
23
    protected $signature = 'run:websocket';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = 'start websocket';
31
32
    /**
33
     * Create a new command instance.
34
     *
35
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
36
     */
37
    public function __construct()
38
    {
39
        parent::__construct();
40
    }
41
42
    /**
43
     * Execute the console command.
44
     *
45
     * @return mixed
46
     */
47
    public function handle()
48
    {
49
50
        $server = IoServer::factory(
51
            new HttpServer(
52
                new WsServer(
53
                    new Receiver()
54
                )
55
            ),
56
            env('CHAT_PORT',8080)
57
        );
58
59
        $server->run();
60
    }
61
}
62