nano4/utils/jsonrpcserver.php

Traits

Server A simple JSON-RPC server framework.

Classes

ServerResponse
ServerError
Exception A generic extension to Exception, and the parent of all below classes.
ParseError Invalid JSON was received by the server.
InvalidRequest The JSON sent is not a valid Request object.
MethodNotFound The method does not exist / is not available.
InvalidParams Invalid method parameter(s).
InternalError Internal JSON-RPC error.

Functions

get_named_param()

get_named_param(Mixed  $params, String  $name, Mixed  $default = null) : Mixed

A helper function to get a named parameter.

Parameters

Mixed $params

The array or object with named parameters.

String $name

The name of the parameter to look for.

Mixed $default

The default value if it's not found.

Returns

Mixed —

The parameter value.

A common use for this is if you want to support both positional and named parameters from the same call. This only works if the first parameter is never an array or object.

public function mymethod ($param1, $param2=null, $param3=null) { $param2 = get_named_param($param1, 'param2', $param2); $param3 = get_named_param($param1, 'param3', $param3); $param1 = get_named_param($param1, 'param1', $param1); // the rest of the function here. }