Some checks failed
continuous-integration/drone/push Build is failing
- Complete GGZ Ecademy Laravel backend application - RESTful API for learning products, members, filters - Authentication and authorization system - Database migrations and seeders - Custom CRUD generator commands - Email notification system - Integration with frontend applications
41 lines
765 B
PHP
41 lines
765 B
PHP
<?php
|
|
|
|
namespace App\Data\Validation;
|
|
|
|
class ValidationResult
|
|
{
|
|
private bool $error;
|
|
private ?string $errorMessage;
|
|
|
|
public function __construct(bool $error, ?string $errorMessage = null)
|
|
{
|
|
$this->error = $error;
|
|
$this->errorMessage = $errorMessage;
|
|
}
|
|
|
|
/**
|
|
* @return void|never
|
|
*/
|
|
final public function assertIsSuccess(): void
|
|
{
|
|
if ($this->isError()) {
|
|
throw new ValidationException($this->getErrorMessage());
|
|
}
|
|
}
|
|
|
|
public function isError(): bool
|
|
{
|
|
return $this->error;
|
|
}
|
|
|
|
public function isSuccess(): bool
|
|
{
|
|
return !$this->isError();
|
|
}
|
|
|
|
public function getErrorMessage(): ?string
|
|
{
|
|
return $this->errorMessage;
|
|
}
|
|
}
|