Passing variable argument list
<p>Given the redundancy, is there a better way to do this? If so, what would it look like?</p>

<p>Note the first <code>$method</code> argument, which is passed as a function name within the <code>$api</code> class, and must not be passed as an argument to the API function. Every argument thereafter might not exist.</p>

<pre><code>function jsonRequest( $method )
{
    $api = new JsonRpcClient( 'https://api.example.com' );
    switch ( func_num_args() ) {
        case 2:
            $result = $api-&gt;$method( 'AccountRef', 'APIKey', func_get_arg( 1 ) );
        break; case 3:
            $result = $api-&gt;$method( 'AccountRef', 'APIKey', func_get_arg( 1 ), func_get_arg( 2 ) );
        break; case 4:
            $result = $api-&gt;$method( 'AccountRef', 'APIKey', func_get_arg( 1 ), func_get_arg( 2 ), func_get_arg( 3 ) );
        break; case 5:
            $result = $api-&gt;$method( 'AccountRef', 'APIKey', func_get_arg( 1 ), func_get_arg( 2 ), func_get_arg( 3 ), func_get_arg( 4 ) );
        break;
    }
    return json_decode( $result );
}
</code></pre>
