<?php

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

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

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

    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $openAPITypes = [
        'identifier' => 'string',
        'year' => 'float',
        'timestamp' => 'float',
        'count' => 'float',
        'visibility' => 'float',
        'sentiment' => 'float',
        'shareOfVoice' => 'float',
        'competitorVisibility' => 'float',
        'competitorSentiment' => 'float',
        'competitorShareOfVoice' => 'float',
        'averageVisibility' => 'float',
        'averageSentiment' => 'float',
        'averageShareOfVoice' => 'float',
        'terms' => '\EdgeBox\SyncCore\V2\Raw\Model\GovernancePromptMonitoringStatsHistoryTermResponse[]',
        'week' => '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 = [
        'identifier' => null,
        'year' => null,
        'timestamp' => null,
        'count' => null,
        'visibility' => null,
        'sentiment' => null,
        'shareOfVoice' => null,
        'competitorVisibility' => null,
        'competitorSentiment' => null,
        'competitorShareOfVoice' => null,
        'averageVisibility' => null,
        'averageSentiment' => null,
        'averageShareOfVoice' => null,
        'terms' => null,
        'week' => null,
    ];

    /**
     * Array of nullable properties. Used for (de)serialization.
     *
     * @var bool[]
     */
    protected static array $openAPINullables = [
        'identifier' => false,
        'year' => false,
        'timestamp' => false,
        'count' => false,
        'visibility' => true,
        'sentiment' => true,
        'shareOfVoice' => true,
        'competitorVisibility' => true,
        'competitorSentiment' => true,
        'competitorShareOfVoice' => true,
        'averageVisibility' => true,
        'averageSentiment' => true,
        'averageShareOfVoice' => true,
        'terms' => true,
        'week' => 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 = [
        'identifier' => 'identifier',
        'year' => 'year',
        'timestamp' => 'timestamp',
        'count' => 'count',
        'visibility' => 'visibility',
        'sentiment' => 'sentiment',
        'shareOfVoice' => 'shareOfVoice',
        'competitorVisibility' => 'competitorVisibility',
        'competitorSentiment' => 'competitorSentiment',
        'competitorShareOfVoice' => 'competitorShareOfVoice',
        'averageVisibility' => 'averageVisibility',
        'averageSentiment' => 'averageSentiment',
        'averageShareOfVoice' => 'averageShareOfVoice',
        'terms' => 'terms',
        'week' => 'week',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'identifier' => 'setIdentifier',
        'year' => 'setYear',
        'timestamp' => 'setTimestamp',
        'count' => 'setCount',
        'visibility' => 'setVisibility',
        'sentiment' => 'setSentiment',
        'shareOfVoice' => 'setShareOfVoice',
        'competitorVisibility' => 'setCompetitorVisibility',
        'competitorSentiment' => 'setCompetitorSentiment',
        'competitorShareOfVoice' => 'setCompetitorShareOfVoice',
        'averageVisibility' => 'setAverageVisibility',
        'averageSentiment' => 'setAverageSentiment',
        'averageShareOfVoice' => 'setAverageShareOfVoice',
        'terms' => 'setTerms',
        'week' => 'setWeek',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'identifier' => 'getIdentifier',
        'year' => 'getYear',
        'timestamp' => 'getTimestamp',
        'count' => 'getCount',
        'visibility' => 'getVisibility',
        'sentiment' => 'getSentiment',
        'shareOfVoice' => 'getShareOfVoice',
        'competitorVisibility' => 'getCompetitorVisibility',
        'competitorSentiment' => 'getCompetitorSentiment',
        'competitorShareOfVoice' => 'getCompetitorShareOfVoice',
        'averageVisibility' => 'getAverageVisibility',
        'averageSentiment' => 'getAverageSentiment',
        'averageShareOfVoice' => 'getAverageShareOfVoice',
        'terms' => 'getTerms',
        'week' => 'getWeek',
    ];

    /**
     * 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('identifier', $data ?? [], null);
        $this->setIfExists('year', $data ?? [], null);
        $this->setIfExists('timestamp', $data ?? [], null);
        $this->setIfExists('count', $data ?? [], null);
        $this->setIfExists('visibility', $data ?? [], null);
        $this->setIfExists('sentiment', $data ?? [], null);
        $this->setIfExists('shareOfVoice', $data ?? [], null);
        $this->setIfExists('competitorVisibility', $data ?? [], null);
        $this->setIfExists('competitorSentiment', $data ?? [], null);
        $this->setIfExists('competitorShareOfVoice', $data ?? [], null);
        $this->setIfExists('averageVisibility', $data ?? [], null);
        $this->setIfExists('averageSentiment', $data ?? [], null);
        $this->setIfExists('averageShareOfVoice', $data ?? [], null);
        $this->setIfExists('terms', $data ?? [], null);
        $this->setIfExists('week', $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['identifier']) {
            $invalidProperties[] = "'identifier' can't be null";
        }
        if (null === $this->container['year']) {
            $invalidProperties[] = "'year' can't be null";
        }
        if (null === $this->container['timestamp']) {
            $invalidProperties[] = "'timestamp' can't be null";
        }
        if (null === $this->container['count']) {
            $invalidProperties[] = "'count' can't be null";
        }
        if (null === $this->container['week']) {
            $invalidProperties[] = "'week' 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 identifier.
     *
     * @return string
     */
    public function getIdentifier()
    {
        return $this->container['identifier'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

    /**
     * Gets terms.
     *
     * @return null|GovernancePromptMonitoringStatsHistoryTermResponse[]
     */
    public function getTerms()
    {
        return $this->container['terms'];
    }

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

        return $this;
    }

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

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

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