You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
802 B

6 years ago
  1. <?php
  2. namespace OSS\Result;
  3. /**
  4. * Class ExistResult 检查bucket和object是否存在的返回结果,
  5. * 根据返回response的http status判断
  6. * @package OSS\Result
  7. */
  8. class ExistResult extends Result
  9. {
  10. /**
  11. * @return bool
  12. */
  13. protected function parseDataFromResponse()
  14. {
  15. return intval($this->rawResponse->status) === 200 ? true : false;
  16. }
  17. /**
  18. * 根据返回http状态码判断,[200-299]即认为是OK, 判断是否存在的接口,404也认为是一种
  19. * 有效响应
  20. *
  21. * @return bool
  22. */
  23. protected function isResponseOk()
  24. {
  25. $status = $this->rawResponse->status;
  26. if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) {
  27. return true;
  28. }
  29. return false;
  30. }
  31. }