<?php

namespace WPDesk\FakturyKSEF\Helpers;

use WPDesk\FakturyKSEF\Xml\DataMapper;
use WPDesk\FakturyKSEF\Xml\Validators\Error;

class XmlErrors {

	/**
	 * @param Error[] $errors
	 *
	 * @return string
	 */
	public static function display_errors( array $errors ): string {
		$output = '';
		foreach ( $errors as $error ) {
			$output .= DataMapper::get_field_name_by_xml_name( $error->get_field_name() ) . ': ' . ( $error->get_translate_message() ?: $error->get_message() ) . ' ';
		}

		return $output;
	}
}
