Code Duplication    Length = 7-7 lines in 3 locations

src/Servitization/Server/TCPServer.php 1 location

@@ 42-48 (lines=7) @@
39
        }
40
        $data = Json::decode($data);
41
        $request = new ServerRequest($data['method'], $data['path']);
42
        if (isset($data['args'])) {
43
            if ('GET' === $request->getMethod()) {
44
                $request->withQueryParams($data['args']);
45
            } else {
46
                $request->withParsedBody($data['args']);
47
            }
48
        }
49
        $response = app()->handleRequest($request);
50
        if (null !== $response->getFileDescriptor()) {
51
            $fd = $response->getFileDescriptor();

src/Servitization/Server/WebSocketServer.php 1 location

@@ 37-43 (lines=7) @@
34
        $data = $frame->data;
35
        $data = Json::decode($data);
36
        $request = new ServerRequest($data['method'], $data['path']);
37
        if (isset($data['args'])) {
38
            if ('GET' === $request->getMethod()) {
39
                $request->withQueryParams($data['args']);
40
            } else {
41
                $request->withParsedBody($data['args']);
42
            }
43
        }
44
        $response = app()->handleRequest($request);
45
        $fd = null !== ($fd = $response->getFileDescriptor()) ? $fd : $frame->fd;
46
        if (false === $server->connection_info($fd)) {

src/Servitization/Server/UDPServer.php 1 location

@@ 36-42 (lines=7) @@
33
    {
34
        $data = Json::decode($data);
35
        $request = new ServerRequest($data['method'], $data['path']);
36
        if (isset($data['args'])) {
37
            if ('GET' === $request->getMethod()) {
38
                $request->withQueryParams($data['args']);
39
            } else {
40
                $request->withParsedBody($data['args']);
41
            }
42
        }
43
        $response = app()->handleRequest($request);
44
        $server->sendto($clientInfo['address'], $clientInfo['port'], (string) $response->getBody());
45
        app()->shutdown($request, $response);