protected function service_class_method_body($function, $params) {
        // Cast the param from object to array (validate_parameters except array only).
        $castingcode = '';
        $paramsstr = '';
        if (!empty($params)) {
            foreach ($params as $paramtocast) {
                // Clean the parameter from any white space.
                $paramtocast = trim($paramtocast);
                $castingcode .= "    $paramtocast = json_decode(json_encode($paramtocast), true);\n";
            }
            $paramsstr = implode(', ', $params);
        }

        $descriptionmethod = $function->methodname . '_returns()';
        $callforreturnvaluedesc = $function->classname . '::' . $descriptionmethod;

        $methodbody = <<<EOD
$castingcode
    if ($callforreturnvaluedesc == null) {
        $function->classname::$function->methodname($paramsstr);
        return null;
    }
    return external_api::clean_returnvalue($callforreturnvaluedesc, $function->classname::$function->methodname($paramsstr));
EOD;
        return $methodbody;
    }
protected function service_class_method_body($function, $params) {
        // Cast the param from object to array (validate_parameters except array only).
        $castingcode = '';
        $paramsstr = '';
        if (!empty($params)) {
            foreach ($params as $paramtocast) {
                // Clean the parameter from any white space.
                $paramtocast = trim($paramtocast);
                $castingcode .= "    $paramtocast = json_decode(json_encode($paramtocast), true);\n";
            }
            $paramsstr = implode(', ', $params);
        }

        $descriptionmethod = $function->methodname . '_returns()';
        $callforreturnvaluedesc = $function->classname . '::' . $descriptionmethod;

        $methodbody = <<<EOD
$castingcode
    if ($callforreturnvaluedesc == null) {
        $function->classname::$function->methodname($paramsstr);
        return null;
    }
    return external_api::clean_returnvalue($callforreturnvaluedesc, $function->classname::$function->methodname($paramsstr));
EOD;
        return $methodbody;
    }
protected function service_class_method_body ( $ function , $ params ) { // Cast the param from object to array (validate_parameters except array only). $ castingcode = '' ; $ paramsstr = '' ; if ( ! empty ( $ params ) ) { foreach ( $ params as $ paramtocast ) { // Clean the parameter from any white space. $ paramtocast = trim ( $ paramtocast ) ; $ castingcode .= "    $paramtocast = json_decode(json_encode($paramtocast), true);\n" ; } $ paramsstr = implode ( ', ' , $ params ) ; } $ descriptionmethod = $ function -> methodname . '_returns()' ; $ callforreturnvaluedesc = $ function -> classname . '::' . $ descriptionmethod ; $ methodbody =  <<<EOD
$castingcode
    if ($callforreturnvaluedesc == null) {
        $function->classname::$function->methodname($paramsstr);
        return null;
    }
    return external_api::clean_returnvalue($callforreturnvaluedesc, $function->classname::$function->methodname($paramsstr));
EOD ; return $ methodbody ; }
Generates the method body of the virtual external function.

@param stdClass $function a record from external_function.
@param array $params web service function parameters.
@return string body of the method for $function ie. everything within the {} of the method declaration.
Generates the method body of the virtual external function .