Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| http_exception | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| getStatusCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getHeaders | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | namespace phpbb\exception; |
| 15 | |
| 16 | use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; |
| 17 | |
| 18 | /** |
| 19 | * Class http_exception |
| 20 | */ |
| 21 | class http_exception extends runtime_exception implements HttpExceptionInterface |
| 22 | { |
| 23 | /** |
| 24 | * Http status code. |
| 25 | * |
| 26 | * @var integer |
| 27 | */ |
| 28 | private int $status_code; |
| 29 | |
| 30 | /** |
| 31 | * Additional headers to set in the response. |
| 32 | * |
| 33 | * @var array |
| 34 | */ |
| 35 | private array $headers; |
| 36 | |
| 37 | /** |
| 38 | * Constructor |
| 39 | * |
| 40 | * @param integer $status_code The http status code. |
| 41 | * @param string $message The Exception message to throw (must be a language variable). |
| 42 | * @param array $parameters The parameters to use with the language var. |
| 43 | * @param \Exception|null $previous The previous exception used for the exception chaining. |
| 44 | * @param array $headers Additional headers to set in the response. |
| 45 | * @param integer $code The Exception code. |
| 46 | */ |
| 47 | public function __construct($status_code, $message = "", array $parameters = array(), \Exception|null $previous = null, array $headers = array(), $code = 0) |
| 48 | { |
| 49 | $this->status_code = $status_code; |
| 50 | $this->headers = $headers; |
| 51 | |
| 52 | parent::__construct($message, $parameters, $previous, $code); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * {@inheritdoc} |
| 57 | */ |
| 58 | public function getStatusCode(): int |
| 59 | { |
| 60 | return $this->status_code; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * {@inheritdoc} |
| 65 | */ |
| 66 | public function getHeaders(): array |
| 67 | { |
| 68 | return $this->headers; |
| 69 | } |
| 70 | } |