diff --git a/src/App/Enums/ExitCode.php b/src/App/Enums/ExitCode.php index 7ceb37c18..2d1745252 100644 --- a/src/App/Enums/ExitCode.php +++ b/src/App/Enums/ExitCode.php @@ -2,8 +2,25 @@ declare(strict_types=1); +/** + * Quantum PHP Framework + * + * An open source software development framework for PHP + * + * @package Quantum + * @author Arman Ag. + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + namespace Quantum\App\Enums; +/** + * Class ExitCode + * @package Quantum\App + * @codeCoverageIgnore + */ final class ExitCode { public const SUCCESS = 0; @@ -11,4 +28,8 @@ final class ExitCode public const FAILURE = 1; public const INVALID = 2; + + private function __construct() + { + } } diff --git a/src/App/Exceptions/StopExecutionException.php b/src/App/Exceptions/StopExecutionException.php deleted file mode 100644 index f8c5e06d1..000000000 --- a/src/App/Exceptions/StopExecutionException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) - * @link http://quantum.softberg.org/ - * @since 3.0.0 - */ - -namespace Quantum\App\Exceptions; - -use Quantum\App\Enums\ExceptionMessages; - -/** - * Class StopExecutionException - * @package Quantum\App - */ -class StopExecutionException extends BaseException -{ - public static function executionTerminated(?int $code): self - { - return new self( - ExceptionMessages::EXECUTION_TERMINATED, - $code ?? 0 - ); - } -} diff --git a/src/App/Helpers/app.php b/src/App/Helpers/app.php index e140c56d4..b9f0b274d 100644 --- a/src/App/Helpers/app.php +++ b/src/App/Helpers/app.php @@ -11,19 +11,3 @@ * @link http://quantum.softberg.org/ * @since 3.0.0 */ - -use Quantum\App\Exceptions\StopExecutionException; - -/** - * Stops the app execution - * @return never - * @throws StopExecutionException - */ -function stop(?Closure $closure = null, ?int $code = 0): void -{ - if ($closure instanceof Closure) { - $closure(); - } - - throw StopExecutionException::executionTerminated($code); -} diff --git a/tests/Unit/Http/Helpers/HttpHelperTest.php b/tests/Unit/Http/Helpers/HttpHelperTest.php index 8cac6966c..6f564b415 100644 --- a/tests/Unit/Http/Helpers/HttpHelperTest.php +++ b/tests/Unit/Http/Helpers/HttpHelperTest.php @@ -2,7 +2,6 @@ namespace Quantum\Tests\Unit\Http\Helpers; -use Quantum\App\Exceptions\StopExecutionException; use Quantum\Session\Factories\SessionFactory; use Quantum\Tests\Unit\AppTestCase; use Quantum\Router\RouteCollection; @@ -104,11 +103,9 @@ public function testRedirecting(): void { $this->assertFalse($this->response->hasHeader('Location')); - try { - redirect('/home'); - } catch (StopExecutionException $e) { + $redirectResponse = redirect('/home'); - } + $this->assertSame($this->response, $redirectResponse); $this->assertTrue($this->response->hasHeader('Location')); @@ -121,11 +118,9 @@ public function testRedirectWithOldData(): void $this->request->create('POST', '/', ['firstname' => 'Josh', 'lastname' => 'Doe']); - try { - redirectWith('/signup', $this->request->all()); - } catch (StopExecutionException $e) { + $redirectResponse = redirectWith('/signup', $this->request->all()); - } + $this->assertSame($this->response, $redirectResponse); $this->assertTrue($this->response->hasHeader('Location'));