UnexpectedResponseException.php 906 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. // Copyright 2019 Hackware SpA <human@hackware.cl>
  3. // This file is part of "Hackware Web Services Payment" and licensed under
  4. // the terms of the GNU Affero General Public License version 3, or (at your
  5. // option) a later version. You should have received a copy of this license
  6. // along with the software. If not, see <https://www.gnu.org/licenses/>.
  7. namespace Hawese\Payment\Exceptions;
  8. use RuntimeException;
  9. class UnexpectedResponseException extends RuntimeException
  10. {
  11. private $detail;
  12. public $status;
  13. public function __construct($response)
  14. {
  15. parent::__construct(
  16. 'Unexpected HTTP response', // message
  17. 2001 // code
  18. );
  19. $this->detail = [
  20. 'body' => $response->getBody(),
  21. ];
  22. $this->status = $response->getStatusCode();
  23. }
  24. public function getDetail()
  25. {
  26. return $this->detail;
  27. }
  28. }