<?php
namespace Fifa\ConnectId\Sdk\Model;

/**
 * Class ValidationResult
 * @package Fifa\ConnectId\Sdk\Model
 */
class ValidationResult
{
    /**
     * @var XmlValidationError[]
     */
    private $errors;

    /**
     * @var bool
     */
    private $isValid;

    /**
     * ValidationResult constructor.
     * @param XmlValidationError[] $errors
     */
    public function __construct(array $errors)
    {
        $this->errors = $errors;
        $this->isValid = empty($errors);
    }

    public function __toString()
    {
        return sprintf('IsValid: %s', $this->isValid ? 'true' : 'false');
    }

    /**
     * @return XmlValidationError[]
     */
    public function getErrors(): array
    {
        return $this->errors;
    }

    /**
     * @return bool
     */
    public function isValid(): bool
    {
        return $this->isValid;
    }
}