Introduced ServiceResult and ServiceResultError interfaces, and respective classes with related methods. These changes were necessary to add and handle service results throughout the app. We now have a standard way to return and handle both successes and errors from our services. This leads to cleaner, clearer, and more maintainable code.
This commit is contained in:
15
app/ServiceResults/ServiceResult.php
Normal file
15
app/ServiceResults/ServiceResult.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\ServiceResults;
|
||||
|
||||
use App\Contracts\ServiceResult as ServiceResultContract;
|
||||
use App\Contracts\ServiceResultError as ServiceResultErrorContract;
|
||||
|
||||
abstract class ServiceResult implements ServiceResultContract
|
||||
{
|
||||
public function isSuccess(): bool
|
||||
{
|
||||
return $this instanceof ServiceResultErrorContract !== true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user