docblocks

This commit is contained in:
Alex Renoki 2020-08-30 20:00:45 +03:00
parent 08110b652e
commit e099c46a0d
1 changed files with 49 additions and 1 deletions

View File

@ -8,26 +8,63 @@ use Ratchet\ConnectionInterface;
class Connection implements ConnectionInterface
{
/** @var Request */
/**
* The request instance.
*
* @var Request
*/
public $httpRequest;
/**
* The sent data through the connection.
*
* @var array
*/
public $sentData = [];
/**
* The raw (unencoded) sent data.
*
* @var array
*/
public $sentRawData = [];
/**
* Wether the connection has been closed.
*
* @var bool
*/
public $closed = false;
/**
* Send the data through the connection.
*
* @param mixed $data
* @return void
*/
public function send($data)
{
$this->sentData[] = json_decode($data, true);
$this->sentRawData[] = $data;
}
/**
* Mark the connection as closed.
*
* @return void
*/
public function close()
{
$this->closed = true;
}
/**
* Assert that an event got sent.
*
* @param string $name
* @param array $additionalParameters
* @return void
*/
public function assertSentEvent(string $name, array $additionalParameters = [])
{
$event = collect($this->sentData)->firstWhere('event', '=', $name);
@ -41,6 +78,12 @@ class Connection implements ConnectionInterface
}
}
/**
* Assert that an event got not sent.
*
* @param string $name
* @return void
*/
public function assertNotSentEvent(string $name)
{
$event = collect($this->sentData)->firstWhere('event', '=', $name);
@ -50,6 +93,11 @@ class Connection implements ConnectionInterface
);
}
/**
* Assert the connection is closed.
*
* @return void
*/
public function assertClosed()
{
PHPUnit::assertTrue($this->closed);