2020-09-10 15:49:42 +08:00
|
|
|
<?php
|
2020-10-29 18:17:25 +08:00
|
|
|
declare(strict_types=1);
|
2020-09-10 15:49:42 +08:00
|
|
|
|
|
|
|
|
namespace Snowflake\Abstracts;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
|
use HttpServer\Exception\ExitException;
|
2020-12-24 11:12:23 +08:00
|
|
|
use Snowflake\Core\Json;
|
2020-09-10 15:49:42 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class BaseGoto
|
|
|
|
|
* @package Snowflake\Abstracts
|
|
|
|
|
*/
|
|
|
|
|
class BaseGoto extends Component
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
2020-12-17 14:09:14 +08:00
|
|
|
* @param string $message
|
2020-09-10 15:49:42 +08:00
|
|
|
* @param int $statusCode
|
2020-12-17 14:09:14 +08:00
|
|
|
* @return mixed
|
|
|
|
|
* @throws ExitException
|
2020-09-10 15:49:42 +08:00
|
|
|
*/
|
2020-12-17 14:09:14 +08:00
|
|
|
public function end(string $message, $statusCode = 200): mixed
|
2020-09-10 15:49:42 +08:00
|
|
|
{
|
2020-12-24 11:12:23 +08:00
|
|
|
throw new ExitException(Json::to(12350, $message), $statusCode);
|
2020-09-10 15:49:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|