* @link https://www.oxidmodule.com */ declare(strict_types=1); namespace D3\MailConfigChecker\Application\Model\Exception; use Assert\LazyAssertionException; use OxidEsales\Eshop\Core\Registry; class d3TranslatableLazyAssertionException extends LazyAssertionException { public static function fromErrors(array $errors): LazyAssertionException { $text = Registry::getLang()->translateString('D3_MAILCHECKER_ASSERTIONS_FAILED'); $message = sprintf( $text, count( $errors ) ) . "\n"; $i = 1; foreach ($errors as $error) { $message .= sprintf( "%d) %s: %s\n", $i ++, $error->getPropertyPath(), $error->getMessage() ); } return new LazyAssertionException($message, $errors); } }