A new method 'isError' has been introduced to the ServiceResult interface and its implementation. This change was made to improve readability and logic. Now instead of checking if the result is not successful, we can directly check if it's an error using isError method. This improves the code clarity.

This commit is contained in:
Leonid Nikitin 2023-07-06 22:31:39 +06:00
parent 91810190b7
commit 6dd24ac1d3
Signed by: kor-elf
GPG Key ID: 7DE8F80C5CEC2C0D
2 changed files with 7 additions and 1 deletions

View File

@ -6,4 +6,5 @@ namespace App\Contracts;
interface ServiceResult
{
public function isSuccess(): bool;
public function isError(): bool;
}

View File

@ -10,6 +10,11 @@ abstract class ServiceResult implements ServiceResultContract
{
public function isSuccess(): bool
{
return $this instanceof ServiceResultErrorContract !== true;
return $this->isError() === false;
}
public function isError(): bool
{
return $this instanceof ServiceResultErrorContract === true;
}
}