<?php

/**
 * RuleTypeSeedDtoPages.
 *
 * PHP version 7.4
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 */

/**
 * Sync Core.
 *
 * The Sync Core that sends and receives content from all connected sites and services for Content Sync.
 *
 * The version of the OpenAPI document: 1.0
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 6.4.0
 */

/**
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace EdgeBox\SyncCore\V2\Raw\Model;

use EdgeBox\SyncCore\V2\Raw\ObjectSerializer;

/**
 * RuleTypeSeedDtoPages Class Doc Comment.
 *
 * @category Class
 *
 * @author   OpenAPI Generator team
 *
 * @see     https://openapi-generator.tech
 *
 * @implements \ArrayAccess<string, mixed>
 */
class RuleTypeSeedDtoPages implements ModelInterface, \ArrayAccess, \JsonSerializable
{
    public const DISCRIMINATOR = null;

    /**
     * The original name of the model.
     *
     * @var string
     */
    protected static $openAPIModelName = 'RuleTypeSeedDto_pages';

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'page' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
        'pageContent' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
        'pageMarkup' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
        'markupElement' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
        'markupTree' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
        'markupLink' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
        'linkAttributes' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
        'urlParts' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
        'markupImage' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
        'imageAttributes' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
    ];

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @var string[]
     *
     * @phpstan-var array<string, string|null>
     *
     * @psalm-var array<string, string|null>
     */
    protected static $openAPIFormats = [
        'page' => null,
        'pageContent' => null,
        'pageMarkup' => null,
        'markupElement' => null,
        'markupTree' => null,
        'markupLink' => null,
        'linkAttributes' => null,
        'urlParts' => null,
        'markupImage' => null,
        'imageAttributes' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'page' => false,
        'pageContent' => false,
        'pageMarkup' => false,
        'markupElement' => false,
        'markupTree' => false,
        'markupLink' => false,
        'linkAttributes' => false,
        'urlParts' => false,
        'markupImage' => false,
        'imageAttributes' => false,
    ];

    /**
     * If a nullable field gets set to null, insert it here.
     *
     * @var bool[]
     */
    protected array $openAPINullablesSetToNull = [];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'page' => 'Page',
        'pageContent' => 'PageContent',
        'pageMarkup' => 'PageMarkup',
        'markupElement' => 'MarkupElement',
        'markupTree' => 'MarkupTree',
        'markupLink' => 'MarkupLink',
        'linkAttributes' => 'LinkAttributes',
        'urlParts' => 'UrlParts',
        'markupImage' => 'MarkupImage',
        'imageAttributes' => 'ImageAttributes',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'page' => 'setPage',
        'pageContent' => 'setPageContent',
        'pageMarkup' => 'setPageMarkup',
        'markupElement' => 'setMarkupElement',
        'markupTree' => 'setMarkupTree',
        'markupLink' => 'setMarkupLink',
        'linkAttributes' => 'setLinkAttributes',
        'urlParts' => 'setUrlParts',
        'markupImage' => 'setMarkupImage',
        'imageAttributes' => 'setImageAttributes',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'page' => 'getPage',
        'pageContent' => 'getPageContent',
        'pageMarkup' => 'getPageMarkup',
        'markupElement' => 'getMarkupElement',
        'markupTree' => 'getMarkupTree',
        'markupLink' => 'getMarkupLink',
        'linkAttributes' => 'getLinkAttributes',
        'urlParts' => 'getUrlParts',
        'markupImage' => 'getMarkupImage',
        'imageAttributes' => 'getImageAttributes',
    ];

    /**
     * Associative array for storing property values.
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor.
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('page', $data ?? [], null);
        $this->setIfExists('pageContent', $data ?? [], null);
        $this->setIfExists('pageMarkup', $data ?? [], null);
        $this->setIfExists('markupElement', $data ?? [], null);
        $this->setIfExists('markupTree', $data ?? [], null);
        $this->setIfExists('markupLink', $data ?? [], null);
        $this->setIfExists('linkAttributes', $data ?? [], null);
        $this->setIfExists('urlParts', $data ?? [], null);
        $this->setIfExists('markupImage', $data ?? [], null);
        $this->setIfExists('imageAttributes', $data ?? [], null);
    }

    /**
     * Gets the string presentation of the object.
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @return array
     */
    public static function openAPITypes()
    {
        return self::$openAPITypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @return array
     */
    public static function openAPIFormats()
    {
        return self::$openAPIFormats;
    }

    /**
     * Checks if a property is nullable.
     */
    public static function isNullable(string $property): bool
    {
        return self::openAPINullables()[$property] ?? false;
    }

    /**
     * Checks if a nullable property is set to null.
     */
    public function isNullableSetToNull(string $property): bool
    {
        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$openAPIModelName;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        if (null === $this->container['page']) {
            $invalidProperties[] = "'page' can't be null";
        }
        if (null === $this->container['pageContent']) {
            $invalidProperties[] = "'pageContent' can't be null";
        }
        if (null === $this->container['pageMarkup']) {
            $invalidProperties[] = "'pageMarkup' can't be null";
        }
        if (null === $this->container['markupElement']) {
            $invalidProperties[] = "'markupElement' can't be null";
        }
        if (null === $this->container['markupTree']) {
            $invalidProperties[] = "'markupTree' can't be null";
        }
        if (null === $this->container['markupLink']) {
            $invalidProperties[] = "'markupLink' can't be null";
        }
        if (null === $this->container['linkAttributes']) {
            $invalidProperties[] = "'linkAttributes' can't be null";
        }
        if (null === $this->container['urlParts']) {
            $invalidProperties[] = "'urlParts' can't be null";
        }
        if (null === $this->container['markupImage']) {
            $invalidProperties[] = "'markupImage' can't be null";
        }
        if (null === $this->container['imageAttributes']) {
            $invalidProperties[] = "'imageAttributes' can't be null";
        }

        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed.
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return 0 === count($this->listInvalidProperties());
    }

    /**
     * Gets page.
     *
     * @return RuleTypeSeedPrimitivesDtoAny
     */
    public function getPage()
    {
        return $this->container['page'];
    }

    /**
     * Sets page.
     *
     * @param RuleTypeSeedPrimitivesDtoAny $page page
     *
     * @return self
     */
    public function setPage($page)
    {
        if (is_null($page)) {
            throw new \InvalidArgumentException('non-nullable page cannot be null');
        }
        $this->container['page'] = $page;

        return $this;
    }

    /**
     * Gets pageContent.
     *
     * @return RuleTypeSeedPrimitivesDtoAny
     */
    public function getPageContent()
    {
        return $this->container['pageContent'];
    }

    /**
     * Sets pageContent.
     *
     * @param RuleTypeSeedPrimitivesDtoAny $pageContent pageContent
     *
     * @return self
     */
    public function setPageContent($pageContent)
    {
        if (is_null($pageContent)) {
            throw new \InvalidArgumentException('non-nullable pageContent cannot be null');
        }
        $this->container['pageContent'] = $pageContent;

        return $this;
    }

    /**
     * Gets pageMarkup.
     *
     * @return RuleTypeSeedPrimitivesDtoAny
     */
    public function getPageMarkup()
    {
        return $this->container['pageMarkup'];
    }

    /**
     * Sets pageMarkup.
     *
     * @param RuleTypeSeedPrimitivesDtoAny $pageMarkup pageMarkup
     *
     * @return self
     */
    public function setPageMarkup($pageMarkup)
    {
        if (is_null($pageMarkup)) {
            throw new \InvalidArgumentException('non-nullable pageMarkup cannot be null');
        }
        $this->container['pageMarkup'] = $pageMarkup;

        return $this;
    }

    /**
     * Gets markupElement.
     *
     * @return RuleTypeSeedPrimitivesDtoAny
     */
    public function getMarkupElement()
    {
        return $this->container['markupElement'];
    }

    /**
     * Sets markupElement.
     *
     * @param RuleTypeSeedPrimitivesDtoAny $markupElement markupElement
     *
     * @return self
     */
    public function setMarkupElement($markupElement)
    {
        if (is_null($markupElement)) {
            throw new \InvalidArgumentException('non-nullable markupElement cannot be null');
        }
        $this->container['markupElement'] = $markupElement;

        return $this;
    }

    /**
     * Gets markupTree.
     *
     * @return RuleTypeSeedPrimitivesDtoAny
     */
    public function getMarkupTree()
    {
        return $this->container['markupTree'];
    }

    /**
     * Sets markupTree.
     *
     * @param RuleTypeSeedPrimitivesDtoAny $markupTree markupTree
     *
     * @return self
     */
    public function setMarkupTree($markupTree)
    {
        if (is_null($markupTree)) {
            throw new \InvalidArgumentException('non-nullable markupTree cannot be null');
        }
        $this->container['markupTree'] = $markupTree;

        return $this;
    }

    /**
     * Gets markupLink.
     *
     * @return RuleTypeSeedPrimitivesDtoAny
     */
    public function getMarkupLink()
    {
        return $this->container['markupLink'];
    }

    /**
     * Sets markupLink.
     *
     * @param RuleTypeSeedPrimitivesDtoAny $markupLink markupLink
     *
     * @return self
     */
    public function setMarkupLink($markupLink)
    {
        if (is_null($markupLink)) {
            throw new \InvalidArgumentException('non-nullable markupLink cannot be null');
        }
        $this->container['markupLink'] = $markupLink;

        return $this;
    }

    /**
     * Gets linkAttributes.
     *
     * @return RuleTypeSeedPrimitivesDtoAny
     */
    public function getLinkAttributes()
    {
        return $this->container['linkAttributes'];
    }

    /**
     * Sets linkAttributes.
     *
     * @param RuleTypeSeedPrimitivesDtoAny $linkAttributes linkAttributes
     *
     * @return self
     */
    public function setLinkAttributes($linkAttributes)
    {
        if (is_null($linkAttributes)) {
            throw new \InvalidArgumentException('non-nullable linkAttributes cannot be null');
        }
        $this->container['linkAttributes'] = $linkAttributes;

        return $this;
    }

    /**
     * Gets urlParts.
     *
     * @return RuleTypeSeedPrimitivesDtoAny
     */
    public function getUrlParts()
    {
        return $this->container['urlParts'];
    }

    /**
     * Sets urlParts.
     *
     * @param RuleTypeSeedPrimitivesDtoAny $urlParts urlParts
     *
     * @return self
     */
    public function setUrlParts($urlParts)
    {
        if (is_null($urlParts)) {
            throw new \InvalidArgumentException('non-nullable urlParts cannot be null');
        }
        $this->container['urlParts'] = $urlParts;

        return $this;
    }

    /**
     * Gets markupImage.
     *
     * @return RuleTypeSeedPrimitivesDtoAny
     */
    public function getMarkupImage()
    {
        return $this->container['markupImage'];
    }

    /**
     * Sets markupImage.
     *
     * @param RuleTypeSeedPrimitivesDtoAny $markupImage markupImage
     *
     * @return self
     */
    public function setMarkupImage($markupImage)
    {
        if (is_null($markupImage)) {
            throw new \InvalidArgumentException('non-nullable markupImage cannot be null');
        }
        $this->container['markupImage'] = $markupImage;

        return $this;
    }

    /**
     * Gets imageAttributes.
     *
     * @return RuleTypeSeedPrimitivesDtoAny
     */
    public function getImageAttributes()
    {
        return $this->container['imageAttributes'];
    }

    /**
     * Sets imageAttributes.
     *
     * @param RuleTypeSeedPrimitivesDtoAny $imageAttributes imageAttributes
     *
     * @return self
     */
    public function setImageAttributes($imageAttributes)
    {
        if (is_null($imageAttributes)) {
            throw new \InvalidArgumentException('non-nullable imageAttributes cannot be null');
        }
        $this->container['imageAttributes'] = $imageAttributes;

        return $this;
    }

    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param int $offset Offset
     */
    public function offsetExists($offset): bool
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param int $offset Offset
     *
     * @return null|mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return $this->container[$offset] ?? null;
    }

    /**
     * Sets value based on offset.
     *
     * @param null|int $offset Offset
     * @param mixed    $value  Value to be set
     */
    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param int $offset Offset
     */
    public function offsetUnset($offset): void
    {
        unset($this->container[$offset]);
    }

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     *
     * @see https://www.php.net/manual/en/jsonserializable.jsonserialize.php
     *
     * @return mixed returns data which can be serialized by json_encode(), which is a value
     * of any type other than a resource
     */
    #[\ReturnTypeWillChange]
    public function jsonSerialize()
    {
        return ObjectSerializer::sanitizeForSerialization($this);
    }

    /**
     * Gets a header-safe presentation of the object.
     *
     * @return string
     */
    public function toHeaderValue()
    {
        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }

    /**
     * Array of nullable properties.
     */
    protected static function openAPINullables(): array
    {
        return self::$openAPINullables;
    }

    /**
     * Array of nullable field names deliberately set to null.
     *
     * @return bool[]
     */
    private function getOpenAPINullablesSetToNull(): array
    {
        return $this->openAPINullablesSetToNull;
    }

    /**
     * Setter - Array of nullable field names deliberately set to null.
     *
     * @param bool[] $openAPINullablesSetToNull
     */
    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
    {
        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
    }

    /**
     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
     * $this->openAPINullablesSetToNull array.
     *
     * @param mixed  $defaultValue
     */
    private function setIfExists(string $variableName, array $fields, $defaultValue): void
    {
        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
            $this->openAPINullablesSetToNull[] = $variableName;
        }

        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
    }
}
