<?php
/**
 * CreateTimeEntryRequest
 *
 * PHP version 8.1
 *
 * @category Class
 * @package  OmsorgCoreClient
 * @author   OpenAPI Generator team
 * @link     https://openapi-generator.tech
 */

/**
 * OmsorgCore.Api
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0
 * Generated by: https://openapi-generator.tech
 * Generator version: 7.14.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 OmsorgCoreClient\Model;

use \ArrayAccess;
use \OmsorgCoreClient\ObjectSerializer;

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

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

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $openAPITypes = [
        'order_id' => 'string',
        'date' => '\DateTime',
        'start' => 'string',
        'end' => 'string',
        'break_duration' => 'string',
        'night_hours' => 'float',
        'saturday_hours' => 'float',
        'sunday_hours' => 'float',
        'holiday_hours' => '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 = [
        'order_id' => 'uuid',
        'date' => 'date',
        'start' => 'time',
        'end' => 'time',
        'break_duration' => 'date-span',
        'night_hours' => 'double',
        'saturday_hours' => 'double',
        'sunday_hours' => 'double',
        'holiday_hours' => 'double'
    ];

    /**
      * Array of nullable properties. Used for (de)serialization
      *
      * @var boolean[]
      */
    protected static array $openAPINullables = [
        'order_id' => false,
        'date' => false,
        'start' => false,
        'end' => false,
        'break_duration' => false,
        'night_hours' => false,
        'saturday_hours' => false,
        'sunday_hours' => false,
        'holiday_hours' => false
    ];

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

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

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

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

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

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

    /**
     * Checks if a nullable property is set to null.
     *
     * @param string $property
     * @return bool
     */
    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
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'order_id' => 'orderId',
        'date' => 'date',
        'start' => 'start',
        'end' => 'end',
        'break_duration' => 'breakDuration',
        'night_hours' => 'nightHours',
        'saturday_hours' => 'saturdayHours',
        'sunday_hours' => 'sundayHours',
        'holiday_hours' => 'holidayHours'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'order_id' => 'setOrderId',
        'date' => 'setDate',
        'start' => 'setStart',
        'end' => 'setEnd',
        'break_duration' => 'setBreakDuration',
        'night_hours' => 'setNightHours',
        'saturday_hours' => 'setSaturdayHours',
        'sunday_hours' => 'setSundayHours',
        'holiday_hours' => 'setHolidayHours'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'order_id' => 'getOrderId',
        'date' => 'getDate',
        'start' => 'getStart',
        'end' => 'getEnd',
        'break_duration' => 'getBreakDuration',
        'night_hours' => 'getNightHours',
        'saturday_hours' => 'getSaturdayHours',
        'sunday_hours' => 'getSundayHours',
        'holiday_hours' => 'getHolidayHours'
    ];

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


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

    /**
     * Constructor
     *
     * @param mixed[]|null $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(?array $data = null)
    {
        $this->setIfExists('order_id', $data ?? [], null);
        $this->setIfExists('date', $data ?? [], null);
        $this->setIfExists('start', $data ?? [], null);
        $this->setIfExists('end', $data ?? [], null);
        $this->setIfExists('break_duration', $data ?? [], null);
        $this->setIfExists('night_hours', $data ?? [], null);
        $this->setIfExists('saturday_hours', $data ?? [], null);
        $this->setIfExists('sunday_hours', $data ?? [], null);
        $this->setIfExists('holiday_hours', $data ?? [], null);
    }

    /**
    * 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 string $variableName
    * @param array  $fields
    * @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;
    }

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

        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 count($this->listInvalidProperties()) === 0;
    }


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

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

        return $this;
    }

    /**
     * Gets date
     *
     * @return \DateTime|null
     */
    public function getDate()
    {
        return $this->container['date'];
    }

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

        return $this;
    }

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

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

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

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

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

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

    /**
     * Serializes the object to a value that can be serialized natively by json_encode().
     * @link 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 the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        return json_encode(
            ObjectSerializer::sanitizeForSerialization($this),
            JSON_PRETTY_PRINT
        );
    }

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


