<?php


namespace Fifa\ConnectId\Sdk\Model\Validation;


class DocumentValidationResult
{
    /**
     * @var string
     */
    private $message;

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

    /**
     * DocumentValidationResult constructor.
     */
    public function __construct()
    {
        $this->isValid = true;
    }

    /**
     * @param $errorMessage
     * @return $this
     */
    public function failed($errorMessage): DocumentValidationResult
    {
        $this->isValid = false;
        $this->message = $errorMessage;
        return $this;
    }

    /**
     * @return string
     */
    public function getMessage(): string
    {
        return $this->message;
    }

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

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