HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/app/Validation/Resources/ValidationResponseData.php
<?php declare(strict_types=1);


namespace App\Validation\Resources;


use Illuminate\Contracts\Support\Arrayable;
use JsonSerializable;

/**
 * Class ValidationResponse
 *
 * @package App\Validation
 */
class ValidationResponseData implements JsonSerializable, Arrayable
{
    /** @var bool */
    private $valid;

    /** @var array */
    private $errors;

    public function __construct()
    {
        $this->valid = false;
        $this->errors = [];
    }


    /**
     * Specify data which should be serialized to JSON
     * @link https://php.net/manual/en/jsonserializable.jsonserialize.php
     * @return mixed data which can be serialized by <b>json_encode</b>,
     * which is a value of any type other than a resource.
     * @since 5.4.0
     */
    public function jsonSerialize()
    {
        return $this->toArray();
    }

    /**
     * Get the instance as an array.
     *
     * @return array
     */
    public function toArray()
    {
        return [
            'valid' => $this->valid,
            'errors' => $this->errors
        ];
    }

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

    /**
     * @param bool $valid
     * @return ValidationResponseData
     */
    public function setValid(bool $valid): ValidationResponseData
    {
        $this->valid = $valid;
        return $this;
    }

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

    /**
     * @param array $errors
     * @return ValidationResponseData
     */
    public function setErrors(array $errors): ValidationResponseData
    {
        $this->errors = $errors;
        return $this;
    }
}