Isn't it a little odd to have connect/disconnect in the constructor/destructor methods?
I have a case where the connection is presumably kept alive until the PHP process ends:
<?php
class MyStompWrapper {
public function doSend()
{
$stomp = $this->connect(); $stomp->send('/destination', 'message', []);
$this->disconnect($stomp);
}
private function disconnect(\Stomp $stompObj)
{
unset($stomp);
}
private function connect():\Stomp
{
return new Stomp('url', 'username', 'password');
}
}
?>
This means that, in order to handle disconnecting, I have to create and destroy the Stomp object within the same scope.