Page MenuHomeWickedGov Phorge

LocalRpcClient.php
No OneTemporary

Size
975 B
Referenced Files
None
Subscribers
None

LocalRpcClient.php

<?php
namespace Shellbox\RPC;
use Shellbox\ShellboxError;
use Throwable;
/**
* An implementation of RPCClient that executes the provided commands locally.
*/
class LocalRpcClient implements RpcClient {
public function call(
string $routeName,
$functionName,
array $params = [],
array $options = []
) {
$binary = !empty( $options['binary'] );
if ( $binary ) {
$params = array_map( static function ( $param ) {
return (string)$param;
}, $params );
}
foreach ( $options['sources' ] ?? [] as $source ) {
require_once $source;
}
// We don't need to require $options['classes'] sources - local client
// is run in the same environment as the calling code, so classes
// be autoloaded.
try {
$result = call_user_func_array( $functionName, $params );
} catch ( Throwable $e ) {
throw new ShellboxError( $e->getMessage(), $e->getCode(), $e );
}
if ( $binary ) {
$result = (string)$result;
}
return $result;
}
}

File Metadata

Mime Type
text/x-php
Expires
Tue, Aug 18, 17:28 (3 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e9/db/d9b633ddfc42e24aca30aaa9f688
Default Alt Text
LocalRpcClient.php (975 B)

Event Timeline