Skip to content

Commit

Permalink
- Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Feb 14, 2020
1 parent 8d4d1ae commit 5a21baa
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 33 deletions.
29 changes: 16 additions & 13 deletions src/IPub/MQTTClient/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace IPub\MQTTClient\Client;

use Closure;
use Exception;

use Nette;

Expand Down Expand Up @@ -51,8 +52,8 @@
* @method onSubscribe(Mqtt\Subscription $subscription, IClient $client)
* @method onUnsubscribe(Mqtt\Subscription $subscription, IClient $client)
* @method onMessage(Mqtt\Message $message, IClient $client)
* @method onWarning(\Exception $ex, IClient $client)
* @method onError(\Exception $ex, IClient $client)
* @method onWarning(Exception $ex, IClient $client)
* @method onError(Exception $ex, IClient $client)
*/
final class Client implements IClient
{
Expand Down Expand Up @@ -239,7 +240,7 @@ public function __construct(
$this->parser = new Mqtt\StreamParser;
}

$this->parser->onError(function (\Exception $ex) {
$this->parser->onError(function (Exception $ex) {
$this->onError($ex, $this);
});

Expand Down Expand Up @@ -315,6 +316,8 @@ public function isConnected() : bool

/**
* {@inheritdoc}
*
* @throws Exceptions\InvalidStateException
*/
public function connect() : Promise\ExtendedPromiseInterface
{
Expand Down Expand Up @@ -352,7 +355,7 @@ public function connect() : Promise\ExtendedPromiseInterface

$deferred->resolve($this->connection);
})
->otherwise(function (\Exception $ex) use ($stream, $deferred, $connection) {
->otherwise(function (Exception $ex) use ($stream, $deferred, $connection) {
$this->isConnecting = FALSE;

$this->onError($ex, $this);
Expand All @@ -366,7 +369,7 @@ public function connect() : Promise\ExtendedPromiseInterface
$this->onClose($connection, $this);
});
})
->otherwise(function (\Exception $ex) use ($deferred) {
->otherwise(function (Exception $ex) use ($deferred) {
$this->isConnecting = FALSE;

$this->onError($ex, $this);
Expand Down Expand Up @@ -467,7 +470,7 @@ public function publishPeriodically(
function ($value) use ($deferred) {
$deferred->notify($value);
},
function (\Exception $e) use ($deferred) {
function (Exception $e) use ($deferred) {
$deferred->reject($e);
}
);
Expand Down Expand Up @@ -506,13 +509,13 @@ private function establishConnection() : Promise\ExtendedPromiseInterface
$this->handleClose();
});

$stream->on('error', function (\Exception $ex) {
$stream->on('error', function (Exception $ex) {
$this->handleError($ex);
});

$deferred->resolve($stream);
})
->otherwise(function (\Exception $ex) use ($deferred) {
->otherwise(function (Exception $ex) use ($deferred) {
$deferred->reject($ex);
});

Expand Down Expand Up @@ -547,7 +550,7 @@ private function registerClient(Mqtt\Connection $connection) : Promise\ExtendedP

$deferred->resolve($connection);

})->otherwise(function (\Exception $ex) use ($deferred) {
})->otherwise(function (Exception $ex) use ($deferred) {
$deferred->reject($ex);
});

Expand Down Expand Up @@ -696,11 +699,11 @@ private function handleClose() : void
/**
* Handles errors of the stream
*
* @param \Exception $ex
* @param Exception $ex
*
* @return void
*/
private function handleError(\Exception $ex) : void
private function handleError(Exception $ex) : void
{
$this->onError($ex, $this);
}
Expand All @@ -718,7 +721,7 @@ private function startFlow(Mqtt\Flow $flow, bool $isSilent = FALSE) : Promise\Ex
try {
$packet = $flow->start();

} catch (\Exception $ex) {
} catch (Exception $ex) {
$this->onError($ex, $this);

return new Promise\RejectedPromise($ex);
Expand Down Expand Up @@ -760,7 +763,7 @@ private function continueFlow(Flow\Envelope $flow, Mqtt\Packet $packet) : void
try {
$response = $flow->next($packet);

} catch (\Exception $ex) {
} catch (Exception $ex) {
$this->onError($ex, $this);

return;
Expand Down
2 changes: 1 addition & 1 deletion src/IPub/MQTTClient/Configuration/Broker.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __construct(
bool $enableDNS = TRUE,
string $dnsAddress = '8.8.8.8',
bool $enableSSL = FALSE,
array $sslSettings,
array $sslSettings = [],
Connection $connection
) {
$this->httpHost = $httpHost;
Expand Down
2 changes: 0 additions & 2 deletions src/IPub/MQTTClient/Events/ErrorEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

use Symfony\Contracts\EventDispatcher;

use BinSoul\Net\Mqtt;

use IPub\MQTTClient\Client;

/**
Expand Down
5 changes: 0 additions & 5 deletions src/IPub/MQTTClient/Events/PingEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
*/
final class PingEvent extends EventDispatcher\Event
{
/**
* @var Mqtt\Connection
*/
private $connection;

/**
* @var Client\IClient
*/
Expand Down
5 changes: 0 additions & 5 deletions src/IPub/MQTTClient/Events/PongEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
*/
final class PongEvent extends EventDispatcher\Event
{
/**
* @var Mqtt\Connection
*/
private $connection;

/**
* @var Client\IClient
*/
Expand Down
2 changes: 1 addition & 1 deletion src/IPub/MQTTClient/Events/SubscribeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class SubscribeEvent extends EventDispatcher\Event
private $client;

/**
* @param Mqtt\Message $message
* @param Mqtt\Subscription $subscription
* @param Client\IClient $client
*/
public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/IPub/MQTTClient/Events/UnsubscribeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class UnsubscribeEvent extends EventDispatcher\Event
private $client;

/**
* @param Mqtt\Message $message
* @param Mqtt\Subscription $subscription
* @param Client\IClient $client
*/
public function __construct(
Expand Down
2 changes: 0 additions & 2 deletions src/IPub/MQTTClient/Events/WarningEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

use Symfony\Contracts\EventDispatcher;

use BinSoul\Net\Mqtt;

use IPub\MQTTClient\Client;

/**
Expand Down
4 changes: 3 additions & 1 deletion src/IPub/MQTTClient/Exceptions/InvalidStateException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace IPub\MQTTClient\Exceptions;

class InvalidStateException extends \Exception implements IException
use Exception;

class InvalidStateException extends Exception implements IException
{
}
2 changes: 1 addition & 1 deletion src/IPub/MQTTClient/Logger/Formatter/IFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace IPub\MQTTClient\Logger\Formatter;

/**
* Client server output formater interface
* Client server output formatter interface
*
* @package iPublikuj:MQTTClient!
* @subpackage Logger
Expand Down
2 changes: 1 addition & 1 deletion src/IPub/MQTTClient/Logger/Formatter/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Symfony\Component\Console;

/**
* Client server symfony console output formater
* Client server symfony console output formatter
*
* @package iPublikuj:MQTTClient!
* @subpackage Logger
Expand Down

0 comments on commit 5a21baa

Please sign in to comment.