ApiClient::getInterface PHP Method

getInterface() private static method

Automatically includes the required ApiClient protocol class.
private static getInterface ( string $version, string $protocol ) : mixed
$version string api version
$protocol string api protocol
return mixed class name or false
    private static function getInterface($version, $protocol)
    {
        $path = DIR . '/version/' . $version . '/';
        if (is_dir($path)) {
            if ($protocol == PROTOCOL_SOAP) {
                $class = SOAP_INTERFACE;
                $classfile = $path . $class . '.php';
            } else {
                if ($protocol == PROTOCOL_XML || $protocol == PROTOCOL_JSON) {
                    $class = RESTFUL_INTERFACE;
                    $classfile = $path . $class . '.php';
                } else {
                    throw new ApiClientException(CLI_ERROR_PROTOCOL);
                }
            }
            if (is_file($classfile)) {
                require_once $classfile;
                if (class_exists($class)) {
                    return $class;
                } else {
                    throw new ApiClientException(CLI_ERROR_PROTOCOL_CLASS);
                }
            } else {
                throw new ApiClientException(CLI_ERROR_PROTOCOL_CLASSFILE);
            }
        } else {
            throw new ApiClientException(CLI_ERROR_VERSION);
        }
    }