<?php

// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

namespace Algolia\AlgoliaSearch\Model\Search;

use Algolia\AlgoliaSearch\Model\AbstractModel;
use Algolia\AlgoliaSearch\Model\ModelInterface;

/**
 * QueryCategorization Class Doc Comment.
 *
 * @category Class
 *
 * @description Query Categorization prediction returned by the AI model. This field is empty when the model cannot categorize the query. See [Query Categorization](https://www.algolia.com/doc/guides/algolia-ai/query-categorization/).
 */
class QueryCategorization extends AbstractModel implements ModelInterface, \ArrayAccess, \JsonSerializable
{
    /**
     * Array of property to type mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $modelTypes = [
        'normalizedQuery' => 'string',
        'count' => 'int',
        'type' => '\Algolia\AlgoliaSearch\Model\Search\QueryCategorizationType',
        'categories' => '\Algolia\AlgoliaSearch\Model\Search\CategoryPrediction[]',
        'autofiltering' => '\Algolia\AlgoliaSearch\Model\Search\AutoFilteringResult',
    ];

    /**
     * Array of property to format mappings. Used for (de)serialization.
     *
     * @var string[]
     */
    protected static $modelFormats = [
        'normalizedQuery' => null,
        'count' => null,
        'type' => null,
        'categories' => null,
        'autofiltering' => null,
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name.
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'normalizedQuery' => 'normalizedQuery',
        'count' => 'count',
        'type' => 'type',
        'categories' => 'categories',
        'autofiltering' => 'autofiltering',
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses).
     *
     * @var string[]
     */
    protected static $setters = [
        'normalizedQuery' => 'setNormalizedQuery',
        'count' => 'setCount',
        'type' => 'setType',
        'categories' => 'setCategories',
        'autofiltering' => 'setAutofiltering',
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests).
     *
     * @var string[]
     */
    protected static $getters = [
        'normalizedQuery' => 'getNormalizedQuery',
        'count' => 'getCount',
        'type' => 'getType',
        'categories' => 'getCategories',
        'autofiltering' => 'getAutofiltering',
    ];

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

    /**
     * Constructor.
     *
     * @param mixed[] $data Associated array of property values
     */
    public function __construct(?array $data = null)
    {
        if (isset($data['normalizedQuery'])) {
            $this->container['normalizedQuery'] = $data['normalizedQuery'];
        }
        if (isset($data['count'])) {
            $this->container['count'] = $data['count'];
        }
        if (isset($data['type'])) {
            $this->container['type'] = $data['type'];
        }
        if (isset($data['categories'])) {
            $this->container['categories'] = $data['categories'];
        }
        if (isset($data['autofiltering'])) {
            $this->container['autofiltering'] = $data['autofiltering'];
        }
    }

    /**
     * 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 property to type mappings. Used for (de)serialization.
     *
     * @return array
     */
    public static function modelTypes()
    {
        return self::$modelTypes;
    }

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

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

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

    /**
     * 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 normalizedQuery.
     *
     * @return null|string
     */
    public function getNormalizedQuery()
    {
        return $this->container['normalizedQuery'] ?? null;
    }

    /**
     * Sets normalizedQuery.
     *
     * @param null|string $normalizedQuery processed and normalized version of the original search query
     *
     * @return self
     */
    public function setNormalizedQuery($normalizedQuery)
    {
        $this->container['normalizedQuery'] = $normalizedQuery;

        return $this;
    }

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

    /**
     * Sets count.
     *
     * @param null|int $count number of times this normalized query was observed during the training window
     *
     * @return self
     */
    public function setCount($count)
    {
        $this->container['count'] = $count;

        return $this;
    }

    /**
     * Gets type.
     *
     * @return null|QueryCategorizationType
     */
    public function getType()
    {
        return $this->container['type'] ?? null;
    }

    /**
     * Sets type.
     *
     * @param null|QueryCategorizationType $type type
     *
     * @return self
     */
    public function setType($type)
    {
        $this->container['type'] = $type;

        return $this;
    }

    /**
     * Gets categories.
     *
     * @return null|CategoryPrediction[]
     */
    public function getCategories()
    {
        return $this->container['categories'] ?? null;
    }

    /**
     * Sets categories.
     *
     * @param null|CategoryPrediction[] $categories list of category predictions with confidence levels
     *
     * @return self
     */
    public function setCategories($categories)
    {
        $this->container['categories'] = $categories;

        return $this;
    }

    /**
     * Gets autofiltering.
     *
     * @return null|AutoFilteringResult
     */
    public function getAutofiltering()
    {
        return $this->container['autofiltering'] ?? null;
    }

    /**
     * Sets autofiltering.
     *
     * @param null|AutoFilteringResult $autofiltering autofiltering
     *
     * @return self
     */
    public function setAutofiltering($autofiltering)
    {
        $this->container['autofiltering'] = $autofiltering;

        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
     */
    public function offsetGet($offset): mixed
    {
        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]);
    }
}
