Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/Service/ReCaptcha/Response.php
Go to the documentation of this file.
00001 <?php
00032 class Zend_Service_ReCaptcha_Response
00033 {
00041     protected $_status = null;
00042 
00051     protected $_errorCode = null;
00052 
00060     public function __construct($status = null, $errorCode = null, Zend_Http_Response $httpResponse = null)
00061     {
00062         if ($status !== null) {
00063             $this->setStatus($status);
00064         }
00065 
00066         if ($errorCode !== null) {
00067             $this->setErrorCode($errorCode);
00068         }
00069 
00070         if ($httpResponse !== null) {
00071             $this->setFromHttpResponse($httpResponse);
00072         }
00073     }
00074 
00081     public function setStatus($status)
00082     {
00083         if ($status === 'true') {
00084             $this->_status = true;
00085         } else {
00086             $this->_status = false;
00087         }
00088 
00089         return $this;
00090     }
00091 
00097     public function getStatus()
00098     {
00099         return $this->_status;
00100     }
00101 
00107     public function isValid()
00108     {
00109         return $this->getStatus();
00110     }
00111 
00118     public function setErrorCode($errorCode)
00119     {
00120         $this->_errorCode = $errorCode;
00121 
00122         return $this;
00123     }
00124 
00130     public function getErrorCode()
00131     {
00132         return $this->_errorCode;
00133     }
00134 
00141     public function setFromHttpResponse(Zend_Http_Response $response)
00142     {
00143         $body = $response->getBody();
00144 
00145         $parts = explode("\n", $body, 2);
00146 
00147         if (count($parts) !== 2) {
00148             $status = 'false';
00149             $errorCode = '';
00150         } else {
00151             list($status, $errorCode) = $parts;
00152         }
00153 
00154         $this->setStatus($status);
00155         $this->setErrorCode($errorCode);
00156 
00157         return $this;
00158     }
00159 }
 All Data Structures Namespaces Files Functions Variables Enumerations