Socket::onMessage()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
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