getBody() public method

public getBody ( )
Beispiel #1
0
 /**
  * Parse XML response
  *
  * @param Gpf_Net_Http_Response $response
  * @return array XML
  */
 protected function parseResult(Gpf_Net_Http_Response $response)
 {
     try {
         $errorMessage = '';
         $xml = @new SimpleXMLElement($response->getBody());
         if ((string) $xml->status === '0' || (string) $xml->result->status === '0') {
             $errorMessage = strlen((string) $xml->statusmsg) ? (string) $xml->statusmsg : (string) $xml->result->statusmsg;
         }
         if ((string) $xml->data->result === '0' && strlen((string) $xml->data->reason)) {
             $errorMessage = (string) $xml->data->reason;
         }
         if (strlen($errorMessage)) {
             throw new Gpf_Exception($errorMessage);
         }
     } catch (Exception $e) {
         throw new Gpf_Exception("Failed to execute CPanel command with error: " . $e->getMessage());
     }
     return $xml;
 }