ExistResult.php 841 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace OSS\Result;
  3. /**
  4. * Class ExistResult checks if bucket or object exists, according to the http status in response headers.
  5. * @package OSS\Result
  6. */
  7. class ExistResult extends Result
  8. {
  9. /**
  10. * @return bool
  11. */
  12. protected function parseDataFromResponse()
  13. {
  14. return intval($this->rawResponse->status) === 200 ? true : false;
  15. }
  16. /**
  17. * Check if the response status is OK according to the http status code.
  18. * [200-299]: OK; [404]: Not found. It means the object or bucket is not found--it's a valid response too.
  19. *
  20. * @return bool
  21. */
  22. protected function isResponseOk()
  23. {
  24. $status = $this->rawResponse->status;
  25. if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) {
  26. return true;
  27. }
  28. return false;
  29. }
  30. }