<?php

namespace dgsoft\ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

/**
 * This class stands for ArrayOfOTA_HotelAvailRSHotelStaysHotelStay ArrayType
 * @package Dg
 * @subpackage Arrays
 */
class DgArrayOfOTA_HotelAvailRSHotelStaysHotelStay extends AbstractStructArrayBase
{
    /**
     * The OTA_HotelAvailRSHotelStaysHotelStay
     * Meta informations extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay[]
     */
    public $OTA_HotelAvailRSHotelStaysHotelStay;
    /**
     * Constructor method for ArrayOfOTA_HotelAvailRSHotelStaysHotelStay
     * @uses DgArrayOfOTA_HotelAvailRSHotelStaysHotelStay::setOTA_HotelAvailRSHotelStaysHotelStay()
     * @param \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay[] $oTA_HotelAvailRSHotelStaysHotelStay
     */
    public function __construct(array $oTA_HotelAvailRSHotelStaysHotelStay = array())
    {
        $this
            ->setOTA_HotelAvailRSHotelStaysHotelStay($oTA_HotelAvailRSHotelStaysHotelStay);
    }
    /**
     * Get OTA_HotelAvailRSHotelStaysHotelStay value
     * An additional test has been added (isset) before returning the property value as
     * this property may have been unset before, due to the fact that this property is
     * removable from the request (nillable=true+minOccurs=0)
     * @return \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay[]|null
     */
    public function getOTA_HotelAvailRSHotelStaysHotelStay()
    {
        return isset($this->OTA_HotelAvailRSHotelStaysHotelStay) ? $this->OTA_HotelAvailRSHotelStaysHotelStay : null;
    }
    /**
     * Set OTA_HotelAvailRSHotelStaysHotelStay value
     * This property is removable from request (nillable=true+minOccurs=0), therefore
     * if the value assigned to this property is null, it is removed from this object
     * @throws \InvalidArgumentException
     * @param \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay[] $oTA_HotelAvailRSHotelStaysHotelStay
     * @return \dgsoft\ArrayType\DgArrayOfOTA_HotelAvailRSHotelStaysHotelStay
     */
    public function setOTA_HotelAvailRSHotelStaysHotelStay(array $oTA_HotelAvailRSHotelStaysHotelStay = array())
    {
        foreach ($oTA_HotelAvailRSHotelStaysHotelStay as $arrayOfOTA_HotelAvailRSHotelStaysHotelStayOTA_HotelAvailRSHotelStaysHotelStayItem) {
            // validation for constraint: itemType
            if (!$arrayOfOTA_HotelAvailRSHotelStaysHotelStayOTA_HotelAvailRSHotelStaysHotelStayItem instanceof \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay) {
                throw new \InvalidArgumentException(sprintf('The OTA_HotelAvailRSHotelStaysHotelStay property can only contain items of \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay, "%s" given', is_object($arrayOfOTA_HotelAvailRSHotelStaysHotelStayOTA_HotelAvailRSHotelStaysHotelStayItem) ? get_class($arrayOfOTA_HotelAvailRSHotelStaysHotelStayOTA_HotelAvailRSHotelStaysHotelStayItem) : gettype($arrayOfOTA_HotelAvailRSHotelStaysHotelStayOTA_HotelAvailRSHotelStaysHotelStayItem)), __LINE__);
            }
        }
        if (is_null($oTA_HotelAvailRSHotelStaysHotelStay) || (is_array($oTA_HotelAvailRSHotelStaysHotelStay) && empty($oTA_HotelAvailRSHotelStaysHotelStay))) {
            unset($this->OTA_HotelAvailRSHotelStaysHotelStay);
        } else {
            $this->OTA_HotelAvailRSHotelStaysHotelStay = $oTA_HotelAvailRSHotelStaysHotelStay;
        }
        return $this;
    }
    /**
     * Add item to OTA_HotelAvailRSHotelStaysHotelStay value
     * @throws \InvalidArgumentException
     * @param \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay $item
     * @return \dgsoft\ArrayType\DgArrayOfOTA_HotelAvailRSHotelStaysHotelStay
     */
    public function addToOTA_HotelAvailRSHotelStaysHotelStay(\dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay) {
            throw new \InvalidArgumentException(sprintf('The OTA_HotelAvailRSHotelStaysHotelStay property can only contain items of \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
        }
        $this->OTA_HotelAvailRSHotelStaysHotelStay[] = $item;
        return $this;
    }
    /**
     * Returns the current element
     * @see AbstractStructArrayBase::current()
     * @return \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay|null
     */
    public function current()
    {
        return parent::current();
    }
    /**
     * Returns the indexed element
     * @see AbstractStructArrayBase::item()
     * @param int $index
     * @return \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay|null
     */
    public function item($index)
    {
        return parent::item($index);
    }
    /**
     * Returns the first element
     * @see AbstractStructArrayBase::first()
     * @return \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay|null
     */
    public function first()
    {
        return parent::first();
    }
    /**
     * Returns the last element
     * @see AbstractStructArrayBase::last()
     * @return \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay|null
     */
    public function last()
    {
        return parent::last();
    }
    /**
     * Returns the element at the offset
     * @see AbstractStructArrayBase::offsetGet()
     * @param int $offset
     * @return \dgsoft\StructType\DgOTA_HotelAvailRSHotelStaysHotelStay|null
     */
    public function offsetGet($offset)
    {
        return parent::offsetGet($offset);
    }
    /**
     * Returns the attribute name
     * @see AbstractStructArrayBase::getAttributeName()
     * @return string OTA_HotelAvailRSHotelStaysHotelStay
     */
    public function getAttributeName()
    {
        return 'OTA_HotelAvailRSHotelStaysHotelStay';
    }
    /**
     * Method called when an object has been exported with var_export() functions
     * It allows to return an object instantiated with the values
     * @see AbstractStructArrayBase::__set_state()
     * @uses AbstractStructArrayBase::__set_state()
     * @param array $array the exported values
     * @return \dgsoft\ArrayType\DgArrayOfOTA_HotelAvailRSHotelStaysHotelStay
     */
    public static function __set_state(array $array)
    {
        return parent::__set_state($array);
    }
    /**
     * Method returning the class name
     * @return string __CLASS__
     */
    public function __toString()
    {
        return __CLASS__;
    }
}
