Socket   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A onOpen() 0 4 1
A onMessage() 0 10 2
A onClose() 0 3 1
A onError() 0 3 1
1
<?php
2
3
namespace BeyondCode\DuskDashboard\Ratchet;
4
5
use BeyondCode\DuskDashboard\DuskProcessFactory;
6
use Ratchet\ConnectionInterface;
7
use Ratchet\RFC6455\Messaging\MessageInterface;
8
use Ratchet\WebSocket\MessageComponentInterface;
9
10
class Socket implements MessageComponentInterface
11
{
12
    public static $connections = [];
13
14
    public function onOpen(ConnectionInterface $connection)
15
    {
16
        self::$connections[] = $connection;
17
    }
18
19
    public function onMessage(ConnectionInterface $from, MessageInterface $msg)
20
    {
21
        $data = json_decode($msg);
22
23
        if ($data->method === 'startTests') {
24
            $process = DuskProcessFactory::make();
25
26
            $process->start();
27
        }
28
    }
29
30
    public function onClose(ConnectionInterface $connection)
31
    {
32
    }
33
34
    public function onError(ConnectionInterface $connection, \Exception $e)
35
    {
36
    }
37
}
38