$errors Array of error messages (if any) */ public function __construct( public bool $success = true, public ?LocalizationFinisherInterface $finisher = null, public array $errors = [] ) {} /** * Create a successful result */ public static function success( LocalizationFinisherInterface $finisher ): self { return new self( success: true, finisher: $finisher ); } /** * Create a failed result with error messages * * @param array $errors */ public static function error(array $errors): self { return new self( success: false, errors: $errors ); } /** * Check if the result has errors */ public function hasErrors(): bool { return !empty($this->errors); } /** * Check if the result is successful */ public function isSuccess(): bool { return $this->success; } /** * Convert to array for JSON serialization */ public function jsonSerialize(): array { $data = [ 'success' => $this->success, ]; if ($this->finisher !== null) { $data['finisher'] = $this->finisher->jsonSerialize(); } if (!empty($this->errors)) { $data['errors'] = $this->errors; } return $data; } }