Skip to content

Commit 7d62bd5

Browse files
committed
Rename Client::send() to sendRequest() and add sendMessage()
1 parent be586b6 commit 7d62bd5

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

src/Client.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,30 @@ public function __construct(Stream $stream, ParserInterface $parser = null, Seri
6565
$this->serializer = $serializer;
6666
}
6767

68-
public function send($name, $args)
68+
/**
69+
* Sends command with given $name and additial $args
70+
*
71+
* @param name $name
72+
* @param array $args
73+
*/
74+
public function sendRequest($name, array $args = array())
6975
{
7076
$this->stream->write($this->serializer->getRequestMessage($name, $args));
7177
}
7278

79+
/**
80+
* Sends given message model (request message)
81+
*
82+
* @param ModelInterface $message
83+
*/
84+
public function sendMessage(ModelInterface $message)
85+
{
86+
$this->stream->write($message->getMessageSerialized($this->serializer));
87+
}
88+
89+
/**
90+
* Immediately terminate the connection and discard incoming and outgoing buffers
91+
*/
7392
public function close()
7493
{
7594
$this->stream->close();

src/ResponseApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __call($name, $args)
3131
$this->client->on('close', array($this, 'handleClose'));
3232
}
3333

34-
$this->client->send($name, $args);
34+
$this->client->sendRequest($name, $args);
3535
$this->requests []= $request;
3636
}
3737

tests/ClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function testSending()
2525
$this->serializer->expects($this->once())->method('getRequestMessage')->with($this->equalTo('ping'))->will($this->returnValue('message'));
2626
$this->stream->expects($this->once())->method('write')->with($this->equalTo('message'));
2727

28-
$this->client->send('ping', array());
28+
$this->client->sendRequest('ping', array());
2929
}
3030

3131
public function testClosingClientEmitsEvent()

tests/ResponseApiTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public function setUp()
1515
{
1616
//$this->stream = $this->getMock('React\Stream\Stream');
1717
//$this->client = new Client($this->stream);
18-
$this->client = $this->getMockBuilder('Clue\React\Redis\Client')->disableOriginalConstructor()->setMethods(array('send', 'close'))->getMock();
18+
$this->client = $this->getMockBuilder('Clue\React\Redis\Client')->disableOriginalConstructor()->setMethods(array('sendRequest', 'close'))->getMock();
1919
$this->responseApi = new ResponseApi($this->client);
2020
}
2121

2222
public function testPingPong()
2323
{
24-
$this->client->expects($this->once())->method('send')->with($this->equalTo('ping'));
24+
$this->client->expects($this->once())->method('sendRequest')->with($this->equalTo('ping'));
2525

2626
$promise = $this->responseApi->ping();
2727

0 commit comments

Comments
 (0)