No Description

BaseResponse.php 868B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace AliyunMNS\Responses;
  3. use AliyunMNS\Exception\MnsException;
  4. abstract class BaseResponse
  5. {
  6. protected $succeed;
  7. protected $statusCode;
  8. abstract public function parseResponse($statusCode, $content);
  9. public function isSucceed()
  10. {
  11. return $this->succeed;
  12. }
  13. public function getStatusCode()
  14. {
  15. return $this->statusCode;
  16. }
  17. protected function loadXmlContent($content)
  18. {
  19. $xmlReader = new \XMLReader();
  20. $isXml = $xmlReader->XML($content);
  21. if ($isXml === FALSE) {
  22. throw new MnsException($this->statusCode, $content);
  23. }
  24. try {
  25. while ($xmlReader->read()) {}
  26. } catch (\Exception $e) {
  27. throw new MnsException($this->statusCode, $content);
  28. }
  29. $xmlReader->XML($content);
  30. return $xmlReader;
  31. }
  32. }
  33. ?>