<?php

/**
 * FunctionDefinitionDto.
 *
 * 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;

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'signatureId' => 'string',
        'name' => 'string',
        'aliases' => 'string[]',
        'category' => 'string',
        'description' => 'string',
        'params' => '\EdgeBox\SyncCore\V2\Raw\Model\FunctionParamDefinitionDto[]',
        'returnType' => '\EdgeBox\SyncCore\V2\Raw\Model\RuleTypeSeedPrimitivesDtoAny',
        'purity' => 'string',
        'batching' => 'bool',
        'redaction' => 'string',
        'hasEstimatedCost' => 'bool',
        'hasStaticEvaluator' => 'bool',
    ];

    /**
     * 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 = [
        'signatureId' => null,
        'name' => null,
        'aliases' => null,
        'category' => null,
        'description' => null,
        'params' => null,
        'returnType' => null,
        'purity' => null,
        'batching' => null,
        'redaction' => null,
        'hasEstimatedCost' => null,
        'hasStaticEvaluator' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'signatureId' => false,
        'name' => false,
        'aliases' => true,
        'category' => true,
        'description' => true,
        'params' => false,
        'returnType' => false,
        'purity' => false,
        'batching' => true,
        'redaction' => true,
        'hasEstimatedCost' => true,
        'hasStaticEvaluator' => true,
    ];

    /**
     * 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 = [
        'signatureId' => 'signatureId',
        'name' => 'name',
        'aliases' => 'aliases',
        'category' => 'category',
        'description' => 'description',
        'params' => 'params',
        'returnType' => 'returnType',
        'purity' => 'purity',
        'batching' => 'batching',
        'redaction' => 'redaction',
        'hasEstimatedCost' => 'hasEstimatedCost',
        'hasStaticEvaluator' => 'hasStaticEvaluator',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'signatureId' => 'setSignatureId',
        'name' => 'setName',
        'aliases' => 'setAliases',
        'category' => 'setCategory',
        'description' => 'setDescription',
        'params' => 'setParams',
        'returnType' => 'setReturnType',
        'purity' => 'setPurity',
        'batching' => 'setBatching',
        'redaction' => 'setRedaction',
        'hasEstimatedCost' => 'setHasEstimatedCost',
        'hasStaticEvaluator' => 'setHasStaticEvaluator',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'signatureId' => 'getSignatureId',
        'name' => 'getName',
        'aliases' => 'getAliases',
        'category' => 'getCategory',
        'description' => 'getDescription',
        'params' => 'getParams',
        'returnType' => 'getReturnType',
        'purity' => 'getPurity',
        'batching' => 'getBatching',
        'redaction' => 'getRedaction',
        'hasEstimatedCost' => 'getHasEstimatedCost',
        'hasStaticEvaluator' => 'getHasStaticEvaluator',
    ];

    /**
     * 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('signatureId', $data ?? [], null);
        $this->setIfExists('name', $data ?? [], null);
        $this->setIfExists('aliases', $data ?? [], null);
        $this->setIfExists('category', $data ?? [], null);
        $this->setIfExists('description', $data ?? [], null);
        $this->setIfExists('params', $data ?? [], null);
        $this->setIfExists('returnType', $data ?? [], null);
        $this->setIfExists('purity', $data ?? [], null);
        $this->setIfExists('batching', $data ?? [], null);
        $this->setIfExists('redaction', $data ?? [], null);
        $this->setIfExists('hasEstimatedCost', $data ?? [], null);
        $this->setIfExists('hasStaticEvaluator', $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['signatureId']) {
            $invalidProperties[] = "'signatureId' can't be null";
        }
        if (null === $this->container['name']) {
            $invalidProperties[] = "'name' can't be null";
        }
        if (null === $this->container['params']) {
            $invalidProperties[] = "'params' can't be null";
        }
        if (null === $this->container['returnType']) {
            $invalidProperties[] = "'returnType' can't be null";
        }
        if (null === $this->container['purity']) {
            $invalidProperties[] = "'purity' 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 signatureId.
     *
     * @return string
     */
    public function getSignatureId()
    {
        return $this->container['signatureId'];
    }

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

        return $this;
    }

    /**
     * Gets name.
     *
     * @return string
     */
    public function getName()
    {
        return $this->container['name'];
    }

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

        return $this;
    }

    /**
     * Gets aliases.
     *
     * @return null|string[]
     */
    public function getAliases()
    {
        return $this->container['aliases'];
    }

    /**
     * Sets aliases.
     *
     * @param null|string[] $aliases aliases
     *
     * @return self
     */
    public function setAliases($aliases)
    {
        if (is_null($aliases)) {
            array_push($this->openAPINullablesSetToNull, 'aliases');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('aliases', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['aliases'] = $aliases;

        return $this;
    }

    /**
     * Gets category.
     *
     * @return null|string
     */
    public function getCategory()
    {
        return $this->container['category'];
    }

    /**
     * Sets category.
     *
     * @param null|string $category category
     *
     * @return self
     */
    public function setCategory($category)
    {
        if (is_null($category)) {
            array_push($this->openAPINullablesSetToNull, 'category');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('category', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['category'] = $category;

        return $this;
    }

    /**
     * Gets description.
     *
     * @return null|string
     */
    public function getDescription()
    {
        return $this->container['description'];
    }

    /**
     * Sets description.
     *
     * @param null|string $description description
     *
     * @return self
     */
    public function setDescription($description)
    {
        if (is_null($description)) {
            array_push($this->openAPINullablesSetToNull, 'description');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('description', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['description'] = $description;

        return $this;
    }

    /**
     * Gets params.
     *
     * @return FunctionParamDefinitionDto[]
     */
    public function getParams()
    {
        return $this->container['params'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets purity.
     *
     * @return string
     */
    public function getPurity()
    {
        return $this->container['purity'];
    }

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

        return $this;
    }

    /**
     * Gets batching.
     *
     * @return null|bool
     */
    public function getBatching()
    {
        return $this->container['batching'];
    }

    /**
     * Sets batching.
     *
     * @param null|bool $batching batching
     *
     * @return self
     */
    public function setBatching($batching)
    {
        if (is_null($batching)) {
            array_push($this->openAPINullablesSetToNull, 'batching');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('batching', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['batching'] = $batching;

        return $this;
    }

    /**
     * Gets redaction.
     *
     * @return null|string
     */
    public function getRedaction()
    {
        return $this->container['redaction'];
    }

    /**
     * Sets redaction.
     *
     * @param null|string $redaction redaction
     *
     * @return self
     */
    public function setRedaction($redaction)
    {
        if (is_null($redaction)) {
            array_push($this->openAPINullablesSetToNull, 'redaction');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('redaction', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['redaction'] = $redaction;

        return $this;
    }

    /**
     * Gets hasEstimatedCost.
     *
     * @return null|bool
     */
    public function getHasEstimatedCost()
    {
        return $this->container['hasEstimatedCost'];
    }

    /**
     * Sets hasEstimatedCost.
     *
     * @param null|bool $hasEstimatedCost hasEstimatedCost
     *
     * @return self
     */
    public function setHasEstimatedCost($hasEstimatedCost)
    {
        if (is_null($hasEstimatedCost)) {
            array_push($this->openAPINullablesSetToNull, 'hasEstimatedCost');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('hasEstimatedCost', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['hasEstimatedCost'] = $hasEstimatedCost;

        return $this;
    }

    /**
     * Gets hasStaticEvaluator.
     *
     * @return null|bool
     */
    public function getHasStaticEvaluator()
    {
        return $this->container['hasStaticEvaluator'];
    }

    /**
     * Sets hasStaticEvaluator.
     *
     * @param null|bool $hasStaticEvaluator hasStaticEvaluator
     *
     * @return self
     */
    public function setHasStaticEvaluator($hasStaticEvaluator)
    {
        if (is_null($hasStaticEvaluator)) {
            array_push($this->openAPINullablesSetToNull, 'hasStaticEvaluator');
        } else {
            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
            $index = array_search('hasStaticEvaluator', $nullablesSetToNull);
            if (false !== $index) {
                unset($nullablesSetToNull[$index]);
                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
            }
        }
        $this->container['hasStaticEvaluator'] = $hasStaticEvaluator;

        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;
    }
}
