protected function getArguments($args, $function = null, $class = null)
    {
        $params = array();
        $method = null;

        // try to get function or method parameter list using reflection
        if ($class !== null && $function !== null && class_exists($class)) {
            $class_reflector = new ReflectionClass($class);
            if ($class_reflector->hasMethod($function)) {
                $method = $class_reflector->getMethod($function);
                $params = $method->getParameters();
            }
        } elseif ($function !== null && function_exists($function)) {
            $method = new ReflectionFunction($function);
            $params = $method->getParameters();
        }

        // display each parameter
        $formatted_values = array();
        for ($i = 0; $i < count($args); $i++) {
            $value = $args[$i];

            if ($method !== null && array_key_exists($i, $params)) {
                $name = $params[$i]->getName();
                $sensitive = $this->isSensitiveParameter($method, $name);
            } else {
                $name = null;
                $sensitive = false;
            }

            if ($name !== null && $sensitive) {
                $formatted_values[] = $this->formatSensitiveParam(
                    $name,
                    $value
                );
            } else {
                $formatted_values[] = $this->formatValue($value);
            }
        }

        return implode(', ', $formatted_values);
    }