1
0
Fork 0

Removed previously added MessageFactory (no longer required)

pull/661/head
dantleech 2018-07-29 15:11:22 +01:00 committed by Daniel Leech
parent af99f0c811
commit 49eada5da8
1 changed files with 0 additions and 32 deletions

View File

@ -1,32 +0,0 @@
<?php
namespace LanguageServer\ProtocolBridge;
use AdvancedJsonRpc\Message as AdvancedJsonRpcMessage;
use LanguageServer\ProtocolBridge\Message;
class MessageFactory
{
/**
* Returns a LSP Message from a raw requets string.
*
* NOTE: This is only used in the MockProtocolStream. Consider moving it
* somewhere else.
*
* @param string $msg
* @return Message
*/
public static function fromRawMessage(string $msg): Message
{
$obj = new Message();
$parts = explode("\r\n", $msg);
$obj->body = AdvancedJsonRpcMessage::parse(array_pop($parts))->__toString();
foreach ($parts as $line) {
if ($line) {
$pair = explode(': ', $line);
$obj->headers[$pair[0]] = $pair[1];
}
}
return $obj;
}
}