Response.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\Core\Api\AbstractApi\Curl;
  3. /**
  4. * Description of Respons
  5. *
  6. * @author Rafał Ossowski <rafal.os@modulesgarden.com>
  7. */
  8. class Response
  9. {
  10. protected $body;
  11. protected $request;
  12. protected $header;
  13. protected $code;
  14. public function setRequest($request)
  15. {
  16. $this->request = $request;
  17. return $this;
  18. }
  19. public function setHeader($header)
  20. {
  21. $this->header = $header;
  22. return $this;
  23. }
  24. public function setBody($body)
  25. {
  26. $this->body = $body;
  27. return $this;
  28. }
  29. public function setCode($code)
  30. {
  31. $this->code = $code;
  32. return $this;
  33. }
  34. /**
  35. * @param bool $isJson
  36. * @return string|\stdClass
  37. */
  38. public function getBody($isJson = true)
  39. {
  40. if ($isJson)
  41. {
  42. return json_decode($this->body);
  43. }
  44. return $this->body;
  45. }
  46. /**
  47. * @return string
  48. */
  49. public function getRequest()
  50. {
  51. return $this->request;
  52. }
  53. /**
  54. * @return string
  55. */
  56. public function getHeader()
  57. {
  58. return $this->header;
  59. }
  60. /**
  61. * @return int
  62. */
  63. public function getCode()
  64. {
  65. return $this->code;
  66. }
  67. /**
  68. * @return bool
  69. */
  70. public function isSuccess()
  71. {
  72. return (bool) ($this->code >= 200 && $this->code < 300);
  73. }
  74. }