PopHttpResponse.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Com\Pdd\Pop\Sdk;
  3. /**
  4. * Pop response 类
  5. */
  6. class PopHttpResponse{
  7. /**
  8. * @var int
  9. */
  10. protected $statusCode;
  11. /**
  12. * @var Header
  13. */
  14. protected $headers;
  15. /**
  16. * @var string
  17. */
  18. protected $body;
  19. /**
  20. * @var array|null
  21. */
  22. protected $content;
  23. /**
  24. * @return int
  25. */
  26. public function getStatusCode()
  27. {
  28. return $this->statusCode;
  29. }
  30. /**
  31. * @param int $statusCode
  32. */
  33. public function setStatusCode($statusCode)
  34. {
  35. $this->statusCode = $statusCode;
  36. }
  37. /**
  38. * @return Header
  39. */
  40. public function getHeaders()
  41. {
  42. return $this->headers;
  43. }
  44. /**
  45. * @param Header $headers
  46. */
  47. public function setHeaders($headers)
  48. {
  49. $this->headers = $headers;
  50. }
  51. /**
  52. * @return string
  53. */
  54. public function getBody()
  55. {
  56. return $this->body;
  57. }
  58. /**
  59. * @param string $body
  60. */
  61. public function setBody($body)
  62. {
  63. $this->body = $body;
  64. }
  65. /**
  66. * @return array|null
  67. */
  68. public function getContent()
  69. {
  70. if($this->content === null){
  71. $this->content = json_decode($this->getBody(),true);
  72. }
  73. return $this->content;
  74. }
  75. /**
  76. * @param array|null $content
  77. */
  78. public function setContent($content)
  79. {
  80. $this->content = $content;
  81. }
  82. }