| Total Complexity | 4 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class XtoolsHttpException extends \RuntimeException |
||
| 12 | { |
||
| 13 | /** @var string What URL to redirect to. */ |
||
| 14 | protected $redirectUrl; |
||
| 15 | |||
| 16 | /** @var array The params to pass in with the URL. */ |
||
| 17 | protected $params; |
||
| 18 | |||
| 19 | /** @var bool Whether the exception was thrown as part of an API request. */ |
||
| 20 | protected $api; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * XtoolsHttpException constructor. |
||
| 24 | * @param string $message |
||
| 25 | * @param string $redirectUrl |
||
| 26 | * @param array $params Params to pass in with the redirect URL. |
||
| 27 | * @param bool $api Whether this is thrown during an API request. |
||
| 28 | */ |
||
| 29 | public function __construct($message, $redirectUrl, $params = [], $api = false) |
||
| 30 | { |
||
| 31 | $this->redirectUrl = $redirectUrl; |
||
| 32 | $this->params = $params; |
||
| 33 | $this->api = $api; |
||
| 34 | |||
| 35 | parent::__construct($message); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * The URL that should be redirected to. |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | public function getRedirectUrl() |
||
| 43 | { |
||
| 44 | return $this->redirectUrl; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Get the configured parameters, which should be the same parameters parsed from the Request, |
||
| 49 | * and passed to the $redirectUrl when handled in the ExceptionListener. |
||
| 50 | * @return array |
||
| 51 | */ |
||
| 52 | public function getParams() |
||
| 53 | { |
||
| 54 | return $this->params; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Whether this exception was thrown as part of a request to the API. |
||
| 59 | * @return bool |
||
| 60 | */ |
||
| 61 | public function isApi() |
||
| 64 | } |
||
| 65 | } |
||
| 66 |