<?php


namespace Fifa\ConnectId\Sdk\Exception;


use Fifa\ConnectId\Sdk\Model\XmlValidationError;

class XmlExceptionHelper
{
    const SEPARATOR = PHP_EOL;
    /**
     * @param XmlValidationError[] $xmlValidationErrors
     * @return string
     */
    public static function flattenErrorMessages(array $xmlValidationErrors): string
    {
        $errorMessage = "";
        foreach ($xmlValidationErrors as $validationError) {
            if($validationError)
            {
                $errorMessage .=  rtrim($validationError->__toString(),  self::SEPARATOR) . self::SEPARATOR;
            }
        }
        return $errorMessage;
    }
}