Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRow committed Jun 30, 2020
1 parent 0cf2ea5 commit 3c0dc0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/NanoIPC.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public function __construct(string $transport_type, array $parameters)
// # Unix domain Socket

if ($transport_type == 'unix_domain_socket') {
if (!isset($parameters['path_to_socket']) || !is_string($parameters['path_to_socket'])) {
throw new NanoIPCException("Invalid path to socket: " . $parameters['path_to_socket']);
if (!isset($params['path_to_socket']) || !is_string($params['path_to_socket'])) {
throw new NanoIPCException("Invalid path to socket: " . $params['path_to_socket']);
}

$this->pathToSocket = $parameters['path_to_socket'];
$this->pathToSocket = $params['path_to_socket'];
$this->transport = stream_socket_client(
"unix://{$this->pathToSocket}",
$this->errorCode,
Expand All @@ -59,22 +59,22 @@ public function __construct(string $transport_type, array $parameters)
// # TCP

} elseif ($transport_type == 'TCP') {
if (!isset($parameters['hostname']) || !is_string($parameters['hostname'])) {
throw new NanoIPCException("Invalid hostname: " . $parameters['hostname']);
if (!isset($params['hostname']) || !is_string($params['hostname'])) {
throw new NanoIPCException("Invalid hostname: " . $params['hostname']);
}
if (!isset($parameters['port']) || !is_int((int) $parameters['port'])) {
throw new NanoIPCException("Invalid port: " . $parameters['port']);
if (!isset($params['port']) || !is_int((int) $params['port'])) {
throw new NanoIPCException("Invalid port: " . $params['port']);
}

if (strpos($parameters['hostname'], 'http://') === 0) {
$parameters['hostname'] = substr($parameters['hostname'], 7);
if (strpos($params['hostname'], 'http://') === 0) {
$params['hostname'] = substr($params['hostname'], 7);
}
if (strpos($parameters['hostname'], 'https://') === 0) {
$parameters['hostname'] = substr($parameters['hostname'], 8);
if (strpos($params['hostname'], 'https://') === 0) {
$params['hostname'] = substr($params['hostname'], 8);
}

$this->hostname = $parameters['hostname'];
$this->port = (int) $parameters['port'];
$this->hostname = $params['hostname'];
$this->port = (int) $params['port'];
$this->transport = stream_socket_client(
"tcp://{$this->hostname}:{$this->port}",
$this->errorCode,
Expand Down
2 changes: 2 additions & 0 deletions src/NanoRPC.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public function __call($method, array $params)

// # Request

$arguments = [];

if (isset($params[0])) {
foreach ($params[0] as $key => $value) {
$arguments[$key] = $value;
Expand Down

0 comments on commit 3c0dc0b

Please sign in to comment.