コード例 #1
0
ファイル: Xml.php プロジェクト: muten84/luigibifulco.it
 /**
  *	Builds and returns a SimpleXmlIterator.
  *
  *	@param string $xml XML document.
  *	@return SimpleXmlIterator Iterator.
  */
 protected static function _iterator($xml)
 {
     try {
         return new SimpleXmlIterator($xml);
     } catch (NativeException $Exception) {
         throw Exception::wrap($Exception);
     }
 }
コード例 #2
0
ファイル: Xml.php プロジェクト: ashliewebb/ashliewebb
 /**
  *	Parses an XML document and returns an array of data.
  *
  *	@param string $xml XML document.
  *	@return array Data.
  */
 public static function parse($xml)
 {
     $internal = libxml_use_internal_errors(true);
     $data = [];
     try {
         $iterator = new SimpleXmlIterator($xml);
     } catch (NativeException $Exception) {
         throw Exception::wrap($Exception);
     }
     foreach ($iterator as $key => $value) {
         $data[$key] = strval($value);
     }
     libxml_use_internal_errors($internal);
     return $data;
 }
コード例 #3
0
ファイル: Exception.php プロジェクト: muten84/luigibifulco.it
 /**
  *	Wraps a native PHP exception.
  *
  *	@param NativeException Native exception.
  *	@return Exception Essence exception.
  */
 public static function wrap(NativeException $Exception)
 {
     return new Exception($Exception->getMessage(), $Exception->getCode(), $Exception);
 }
コード例 #4
0
ファイル: Exception.php プロジェクト: ashliewebb/ashliewebb
 /**
  *	Constructs the exception with the given HTTP status code, and the URL
  *	that triggered the error.
  *
  *	@param string $url URL.
  *	@param int $code HTTP status code.
  *	@param Exception $Previous Previous exception.
  */
 public function __construct($url, $code = 0, Exception $Previous = null)
 {
     $this->_url = $url;
     parent::__construct(isset($this->_messages[$code]) ? $this->_messages[$code] : 'HTTP error', $code, $Previous);
 }