forked from phpactor/language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestRpcClient.php
More file actions
46 lines (37 loc) · 1.24 KB
/
TestRpcClient.php
File metadata and controls
46 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Phpactor\LanguageServer\Core\Server\RpcClient;
use Amp\Promise;
use Phpactor\LanguageServer\Core\Server\ResponseWatcher\TestResponseWatcher;
use Phpactor\LanguageServer\Core\Server\RpcClient;
use Phpactor\LanguageServer\Core\Server\Transmitter\TestMessageTransmitter;
final class TestRpcClient implements RpcClient
{
private JsonRpcClient $client;
public function __construct(private TestMessageTransmitter $transmitter, private TestResponseWatcher $responseWatcher)
{
$this->client = new JsonRpcClient($this->transmitter, $this->responseWatcher);
}
public static function create(): TestRpcClient
{
return new self(new TestMessageTransmitter(), new TestResponseWatcher());
}
public function notification(string $method, array $params): void
{
$this->client->notification($method, $params);
}
/**
* {@inheritDoc}
*/
public function request(string $method, array $params): Promise
{
return $this->client->request($method, $params);
}
public function responseWatcher(): TestResponseWatcher
{
return $this->responseWatcher;
}
public function transmitter(): TestMessageTransmitter
{
return $this->transmitter;
}
}