public function getProxiedService($type)
{
// Sequence validation
$this->ensureIsProxy();
$this->ensureAuthenticationCallSuccessful();
// Argument validation
if (gettype($type) != 'string') {
throw new CAS_TypeMismatchException($type, '$type', 'string');
}
switch ($type) {
case PHPCAS_PROXIED_SERVICE_HTTP_GET:
case PHPCAS_PROXIED_SERVICE_HTTP_POST:
$requestClass = $this->_requestImplementation;
$request = new $requestClass();
if (count($this->_curl_options)) {
$request->setCurlOptions($this->_curl_options);
}
$proxiedService = new $type($request, $this->_serviceCookieJar);
if ($proxiedService instanceof CAS_ProxiedService_Testable) {
$proxiedService->setCasClient($this);
}
return $proxiedService;
case PHPCAS_PROXIED_SERVICE_IMAP:
$proxiedService = new CAS_ProxiedService_Imap($this->_getUser());
if ($proxiedService instanceof CAS_ProxiedService_Testable) {
$proxiedService->setCasClient($this);
}
return $proxiedService;
default:
throw new CAS_InvalidArgumentException("Unknown proxied-service type, {$type}.");
}
}