Example #1
0
 /**
  * Get service instance
  *
  * @param $type
  * @return mixed
  * @throws \Exception
  */
 public function getService($type)
 {
     if (empty($this->params)) {
         $this->params = $this->getParams();
     }
     if ($type == 'captcha') {
         if (!isset($this->params['captcha'])) {
             throw new ParamsNotFoundException('Google captcha params not exist');
         }
         if (!isset($this->services['captcha'])) {
             if (!function_exists('curl_version')) {
                 throw new \Exception('Curl library is not installed');
             }
             $captchaConfig = new CaptchaConfiguration();
             $captchaConfig->build($this->params['captcha']);
             $this->services['captcha'] = new CaptchaBuilder($captchaConfig);
         }
         return $this->services['captcha'];
     } else {
         throw new \Exception('Service type ' . $type . ' not exist');
     }
 }