Example #1
0
 /**
  * recreate this error document from a generated string
  * @param string $string
  * @return Xml $errorResponse
  */
 public static function createFromString($string)
 {
     $instance = new self();
     $parts = explode(':', $string);
     $instance->setMessages(explode(', ', $parts[1]));
     return $instance;
 }
Example #2
0
 /**
  * Every error document you should be able to recreate from the generated string
  * @param string $string
  * @return Json $errorResponse
  */
 public static function createFromString($string)
 {
     $result = json_decode($string, true);
     $instance = new self();
     if (isset($result['error'])) {
         $instance->setMessages($result['error']);
     }
     return $instance;
 }
Example #3
0
 /**
  * recreate this error document from a generated string
  * @param string $string
  * @throws \Exception
  * @return Xml $errorResponse
  */
 public static function createFromString($string)
 {
     $instance = new self();
     $xml = new \DomDocument('1.0', 'UTF-8');
     $xml->formatOutput = true;
     if (!$xml->loadXML($string)) {
         throw new \Exception('Unable to load XML document from string');
     }
     $instance->setMessages($xml->documentElement->textContent);
     return $instance;
 }