<?php

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'targetType' => 'IssueTargetType',
        'healthCheck' => '\EdgeBox\SyncCore\V2\Raw\Model\TermAssignmentTerm',
        'contentItem' => 'DynamicRevisionReference',
        'contentGroup' => 'DynamicReference',
        'site' => 'DynamicReference',
        'issueType' => '\EdgeBox\SyncCore\V2\Raw\Model\TermAssignmentTerm',
        'key' => 'string',
        'status' => 'IssueStatus',
        'firstDetectedAt' => 'float',
        'lastDetectedAt' => 'float',
        'resolvedAt' => 'float',
        'evidence' => '\EdgeBox\SyncCore\V2\Raw\Model\IssueEvidenceItem[]',
        'customer' => '\EdgeBox\SyncCore\V2\Raw\Model\RuntimeRemoteEntityDependencyWithDependenciesEntity',
        'project' => '\EdgeBox\SyncCore\V2\Raw\Model\RuntimeRemoteEntityDependencyWithDependenciesEntity',
        'id' => 'string',
        'createdAt' => 'float',
        'updatedAt' => 'float',
        'deletedAt' => 'float',
    ];

    /**
     * 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 = [
        'targetType' => null,
        'healthCheck' => null,
        'contentItem' => null,
        'contentGroup' => null,
        'site' => null,
        'issueType' => null,
        'key' => null,
        'status' => null,
        'firstDetectedAt' => null,
        'lastDetectedAt' => null,
        'resolvedAt' => null,
        'evidence' => null,
        'customer' => null,
        'project' => null,
        'id' => null,
        'createdAt' => null,
        'updatedAt' => null,
        'deletedAt' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'targetType' => false,
        'healthCheck' => false,
        'contentItem' => true,
        'contentGroup' => true,
        'site' => true,
        'issueType' => false,
        'key' => false,
        'status' => false,
        'firstDetectedAt' => false,
        'lastDetectedAt' => false,
        'resolvedAt' => true,
        'evidence' => true,
        'customer' => false,
        'project' => false,
        'id' => false,
        'createdAt' => false,
        'updatedAt' => false,
        'deletedAt' => 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 = [
        'targetType' => 'targetType',
        'healthCheck' => 'healthCheck',
        'contentItem' => 'contentItem',
        'contentGroup' => 'contentGroup',
        'site' => 'site',
        'issueType' => 'issueType',
        'key' => 'key',
        'status' => 'status',
        'firstDetectedAt' => 'firstDetectedAt',
        'lastDetectedAt' => 'lastDetectedAt',
        'resolvedAt' => 'resolvedAt',
        'evidence' => 'evidence',
        'customer' => 'customer',
        'project' => 'project',
        'id' => 'id',
        'createdAt' => 'createdAt',
        'updatedAt' => 'updatedAt',
        'deletedAt' => 'deletedAt',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'targetType' => 'setTargetType',
        'healthCheck' => 'setHealthCheck',
        'contentItem' => 'setContentItem',
        'contentGroup' => 'setContentGroup',
        'site' => 'setSite',
        'issueType' => 'setIssueType',
        'key' => 'setKey',
        'status' => 'setStatus',
        'firstDetectedAt' => 'setFirstDetectedAt',
        'lastDetectedAt' => 'setLastDetectedAt',
        'resolvedAt' => 'setResolvedAt',
        'evidence' => 'setEvidence',
        'customer' => 'setCustomer',
        'project' => 'setProject',
        'id' => 'setId',
        'createdAt' => 'setCreatedAt',
        'updatedAt' => 'setUpdatedAt',
        'deletedAt' => 'setDeletedAt',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'targetType' => 'getTargetType',
        'healthCheck' => 'getHealthCheck',
        'contentItem' => 'getContentItem',
        'contentGroup' => 'getContentGroup',
        'site' => 'getSite',
        'issueType' => 'getIssueType',
        'key' => 'getKey',
        'status' => 'getStatus',
        'firstDetectedAt' => 'getFirstDetectedAt',
        'lastDetectedAt' => 'getLastDetectedAt',
        'resolvedAt' => 'getResolvedAt',
        'evidence' => 'getEvidence',
        'customer' => 'getCustomer',
        'project' => 'getProject',
        'id' => 'getId',
        'createdAt' => 'getCreatedAt',
        'updatedAt' => 'getUpdatedAt',
        'deletedAt' => 'getDeletedAt',
    ];

    /**
     * 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('targetType', $data ?? [], null);
        $this->setIfExists('healthCheck', $data ?? [], null);
        $this->setIfExists('contentItem', $data ?? [], null);
        $this->setIfExists('contentGroup', $data ?? [], null);
        $this->setIfExists('site', $data ?? [], null);
        $this->setIfExists('issueType', $data ?? [], null);
        $this->setIfExists('key', $data ?? [], null);
        $this->setIfExists('status', $data ?? [], null);
        $this->setIfExists('firstDetectedAt', $data ?? [], null);
        $this->setIfExists('lastDetectedAt', $data ?? [], null);
        $this->setIfExists('resolvedAt', $data ?? [], null);
        $this->setIfExists('evidence', $data ?? [], null);
        $this->setIfExists('customer', $data ?? [], null);
        $this->setIfExists('project', $data ?? [], null);
        $this->setIfExists('id', $data ?? [], null);
        $this->setIfExists('createdAt', $data ?? [], null);
        $this->setIfExists('updatedAt', $data ?? [], null);
        $this->setIfExists('deletedAt', $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['targetType']) {
            $invalidProperties[] = "'targetType' can't be null";
        }
        if (null === $this->container['healthCheck']) {
            $invalidProperties[] = "'healthCheck' can't be null";
        }
        if (null === $this->container['issueType']) {
            $invalidProperties[] = "'issueType' can't be null";
        }
        if (null === $this->container['key']) {
            $invalidProperties[] = "'key' can't be null";
        }
        if (null === $this->container['status']) {
            $invalidProperties[] = "'status' can't be null";
        }
        if (null === $this->container['firstDetectedAt']) {
            $invalidProperties[] = "'firstDetectedAt' can't be null";
        }
        if (null === $this->container['lastDetectedAt']) {
            $invalidProperties[] = "'lastDetectedAt' can't be null";
        }
        if (null === $this->container['customer']) {
            $invalidProperties[] = "'customer' can't be null";
        }
        if (null === $this->container['project']) {
            $invalidProperties[] = "'project' can't be null";
        }
        if (null === $this->container['id']) {
            $invalidProperties[] = "'id' can't be null";
        }
        if (null === $this->container['createdAt']) {
            $invalidProperties[] = "'createdAt' can't be null";
        }
        if (null === $this->container['updatedAt']) {
            $invalidProperties[] = "'updatedAt' 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 targetType.
     *
     * @return IssueTargetType
     */
    public function getTargetType()
    {
        return $this->container['targetType'];
    }

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

        return $this;
    }

    /**
     * Gets healthCheck.
     *
     * @return TermAssignmentTerm
     */
    public function getHealthCheck()
    {
        return $this->container['healthCheck'];
    }

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

        return $this;
    }

    /**
     * Gets contentItem.
     *
     * @return null|DynamicRevisionReference
     */
    public function getContentItem()
    {
        return $this->container['contentItem'];
    }

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

        return $this;
    }

    /**
     * Gets contentGroup.
     *
     * @return null|DynamicReference
     */
    public function getContentGroup()
    {
        return $this->container['contentGroup'];
    }

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

        return $this;
    }

    /**
     * Gets site.
     *
     * @return null|DynamicReference
     */
    public function getSite()
    {
        return $this->container['site'];
    }

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

        return $this;
    }

    /**
     * Gets issueType.
     *
     * @return TermAssignmentTerm
     */
    public function getIssueType()
    {
        return $this->container['issueType'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets status.
     *
     * @return IssueStatus
     */
    public function getStatus()
    {
        return $this->container['status'];
    }

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

        return $this;
    }

    /**
     * Gets firstDetectedAt.
     *
     * @return float
     */
    public function getFirstDetectedAt()
    {
        return $this->container['firstDetectedAt'];
    }

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

        return $this;
    }

    /**
     * Gets lastDetectedAt.
     *
     * @return float
     */
    public function getLastDetectedAt()
    {
        return $this->container['lastDetectedAt'];
    }

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

        return $this;
    }

    /**
     * Gets resolvedAt.
     *
     * @return null|float
     */
    public function getResolvedAt()
    {
        return $this->container['resolvedAt'];
    }

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

        return $this;
    }

    /**
     * Gets evidence.
     *
     * @return null|IssueEvidenceItem[]
     */
    public function getEvidence()
    {
        return $this->container['evidence'];
    }

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

        return $this;
    }

    /**
     * Gets customer.
     *
     * @return RuntimeRemoteEntityDependencyWithDependenciesEntity
     */
    public function getCustomer()
    {
        return $this->container['customer'];
    }

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

        return $this;
    }

    /**
     * Gets project.
     *
     * @return RuntimeRemoteEntityDependencyWithDependenciesEntity
     */
    public function getProject()
    {
        return $this->container['project'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets createdAt.
     *
     * @return float
     */
    public function getCreatedAt()
    {
        return $this->container['createdAt'];
    }

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

        return $this;
    }

    /**
     * Gets updatedAt.
     *
     * @return float
     */
    public function getUpdatedAt()
    {
        return $this->container['updatedAt'];
    }

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

        return $this;
    }

    /**
     * Gets deletedAt.
     *
     * @return null|float
     */
    public function getDeletedAt()
    {
        return $this->container['deletedAt'];
    }

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

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