Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| RequestException | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getRequest | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | /** |
| 4 | * Pop PHP Framework (https://www.popphp.org/) |
| 5 | * |
| 6 | * @link https://github.com/popphp/popphp-framework |
| 7 | * @author Nick Sagona, III <nick@popphp.org> |
| 8 | * @copyright Copyright (c) 2009-2026 Nick Sagona, III |
| 9 | * @license https://www.popphp.org/license New BSD License |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * @namespace |
| 14 | */ |
| 15 | namespace Pop\Http\Client; |
| 16 | |
| 17 | use Psr\Http\Client\RequestExceptionInterface; |
| 18 | use Psr\Http\Message\RequestInterface; |
| 19 | |
| 20 | /** |
| 21 | * HTTP client request exception class - thrown by Client::sendRequest() for |
| 22 | * pre-dispatch validation failures (e.g. no request URI to send) |
| 23 | * |
| 24 | * @category Pop |
| 25 | * @package Pop\Http |
| 26 | * @author Nick Sagona, III <nick@popphp.org> |
| 27 | * @copyright Copyright (c) 2009-2026 Nick Sagona, III |
| 28 | * @license https://www.popphp.org/license New BSD License |
| 29 | * @version 6.0.0 |
| 30 | */ |
| 31 | class RequestException extends Exception implements RequestExceptionInterface |
| 32 | { |
| 33 | |
| 34 | /** |
| 35 | * The request that failed to dispatch |
| 36 | * @var RequestInterface |
| 37 | */ |
| 38 | protected RequestInterface $request; |
| 39 | |
| 40 | /** |
| 41 | * Constructor |
| 42 | * |
| 43 | * @param string $message |
| 44 | * @param RequestInterface $request |
| 45 | * @param int $code |
| 46 | * @param ?\Throwable $previous |
| 47 | */ |
| 48 | public function __construct(string $message, RequestInterface $request, int $code = 0, ?\Throwable $previous = null) |
| 49 | { |
| 50 | parent::__construct($message, $code, $previous); |
| 51 | $this->request = $request; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Get the request that failed to dispatch |
| 56 | * |
| 57 | * @return RequestInterface |
| 58 | */ |
| 59 | public function getRequest(): RequestInterface |
| 60 | { |
| 61 | return $this->request; |
| 62 | } |
| 63 | |
| 64 | } |