src/Protocol/EasyDataGram.php
private function unpack(string $raw)
    {
        if (null === ($data = json_decode($raw, true)) && json_last_error() > 0) {
            throw new ReadException('Cannot decode json packet.', ReadException::ERROR_PROTOCOL);
        }
        if (!isset($data['type']) || !isset($data['data']) || !isset($data['id'])) {
            throw new ReadException('Invalid packet received.', ReadException::ERROR_PROTOCOL);
        }
        switch ($data['type']) {
            case 'string':
            case 'array':
                $data = $data['data'];
                break;
            case 'integer':
                $data = (int)$data['data'];
                break;
            case 'float':
                $data = (float)$data['data'];
                break;
            case 'double':
                $data = (double)$data['data'];
                break;
            case 'object':
                $data = unserialize($data['data']);
                break;
            default:
                throw new ReadException(
                    sprintf(
                        'Unknown packet data type "%s".',
                        $data['type']
                    ), ReadException::ERROR_PROTOCOL
                );
        }
        return $data;
    }
private function unpack(string $raw)
    {
        if (null === ($data = json_decode($raw, true)) && json_last_error() > 0) {
            throw new ReadException('Cannot decode json packet.', ReadException::ERROR_PROTOCOL);
        }
        if (!isset($data['type']) || !isset($data['data']) || !isset($data['id'])) {
            throw new ReadException('Invalid packet received.', ReadException::ERROR_PROTOCOL);
        }
        switch ($data['type']) {
            case 'string':
            case 'array':
                $data = $data['data'];
                break;
            case 'integer':
                $data = (int)$data['data'];
                break;
            case 'float':
                $data = (float)$data['data'];
                break;
            case 'double':
                $data = (double)$data['data'];
                break;
            case 'object':
                $data = unserialize($data['data']);
                break;
            default:
                throw new ReadException(
                    sprintf(
                        'Unknown packet data type "%s".',
                        $data['type']
                    ), ReadException::ERROR_PROTOCOL
                );
        }
        return $data;
    }
Распаковывает принятые из сокета данные.
Возвращает null если данные не были распакованы по неизвестным причинам.

@param string $raw

@return mixed
@throws ReadException