<?php
use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

/**
 * This class stands for ArrayOfRichiestaCartellino_Evento ArrayType
 * Meta information extracted from the WSDL
 * - nillable: true
 * - type: tns:ArrayOfRichiestaCartellino_Evento
 * @subpackage Arrays
 */
class ArrayOfRichiestaCartellino_Evento extends AbstractStructArrayBase
{
    /**
     * The RichiestaCartellino_Evento
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var RichiestaCartellino_Evento[]
     */
    public $RichiestaCartellino_Evento;
    /**
     * Constructor method for ArrayOfRichiestaCartellino_Evento
     * @uses ArrayOfRichiestaCartellino_Evento::setRichiestaCartellino_Evento()
     * @param RichiestaCartellino_Evento[] $richiestaCartellino_Evento
     */
    public function __construct(array $richiestaCartellino_Evento = array())
    {
        $this
            ->setRichiestaCartellino_Evento($richiestaCartellino_Evento);
    }
    /**
     * Get RichiestaCartellino_Evento 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 RichiestaCartellino_Evento[]|null
     */
    public function getRichiestaCartellino_Evento()
    {
        return isset($this->RichiestaCartellino_Evento) ? $this->RichiestaCartellino_Evento : null;
    }
    /**
     * This method is responsible for validating the values passed to the setRichiestaCartellino_Evento method
     * This method is willingly generated in order to preserve the one-line inline validation within the setRichiestaCartellino_Evento method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateRichiestaCartellino_EventoForArrayConstraintsFromSetRichiestaCartellino_Evento(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $arrayOfRichiestaCartellino_EventoRichiestaCartellino_EventoItem) {
            // validation for constraint: itemType
            if (!$arrayOfRichiestaCartellino_EventoRichiestaCartellino_EventoItem instanceof RichiestaCartellino_Evento) {
                $invalidValues[] = is_object($arrayOfRichiestaCartellino_EventoRichiestaCartellino_EventoItem) ? get_class($arrayOfRichiestaCartellino_EventoRichiestaCartellino_EventoItem) : sprintf('%s(%s)', gettype($arrayOfRichiestaCartellino_EventoRichiestaCartellino_EventoItem), var_export($arrayOfRichiestaCartellino_EventoRichiestaCartellino_EventoItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The RichiestaCartellino_Evento property can only contain items of type RichiestaCartellino_Evento, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set RichiestaCartellino_Evento 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 RichiestaCartellino_Evento[] $richiestaCartellino_Evento
     * @return ArrayOfRichiestaCartellino_Evento
     */
    public function setRichiestaCartellino_Evento(array $richiestaCartellino_Evento = array())
    {
        // validation for constraint: array
        if ('' !== ($richiestaCartellino_EventoArrayErrorMessage = self::validateRichiestaCartellino_EventoForArrayConstraintsFromSetRichiestaCartellino_Evento($richiestaCartellino_Evento))) {
            throw new \InvalidArgumentException($richiestaCartellino_EventoArrayErrorMessage, __LINE__);
        }
        if (is_null($richiestaCartellino_Evento) || (is_array($richiestaCartellino_Evento) && empty($richiestaCartellino_Evento))) {
            unset($this->RichiestaCartellino_Evento);
        } else {
            $this->RichiestaCartellino_Evento = $richiestaCartellino_Evento;
        }
        return $this;
    }
    /**
     * Add item to RichiestaCartellino_Evento value
     * @throws \InvalidArgumentException
     * @param RichiestaCartellino_Evento $item
     * @return ArrayOfRichiestaCartellino_Evento
     */
    public function addToRichiestaCartellino_Evento(RichiestaCartellino_Evento $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof RichiestaCartellino_Evento) {
            throw new \InvalidArgumentException(sprintf('The RichiestaCartellino_Evento property can only contain items of type RichiestaCartellino_Evento, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->RichiestaCartellino_Evento[] = $item;
        return $this;
    }
    /**
     * Returns the current element
     * @see AbstractStructArrayBase::current()
     * @return RichiestaCartellino_Evento|null
     */
    public function current()
    {
        return parent::current();
    }
    /**
     * Returns the indexed element
     * @see AbstractStructArrayBase::item()
     * @param int $index
     * @return RichiestaCartellino_Evento|null
     */
    public function item($index)
    {
        return parent::item($index);
    }
    /**
     * Returns the first element
     * @see AbstractStructArrayBase::first()
     * @return RichiestaCartellino_Evento|null
     */
    public function first()
    {
        return parent::first();
    }
    /**
     * Returns the last element
     * @see AbstractStructArrayBase::last()
     * @return RichiestaCartellino_Evento|null
     */
    public function last()
    {
        return parent::last();
    }
    /**
     * Returns the element at the offset
     * @see AbstractStructArrayBase::offsetGet()
     * @param int $offset
     * @return RichiestaCartellino_Evento|null
     */
    public function offsetGet($offset)
    {
        return parent::offsetGet($offset);
    }
    /**
     * Returns the attribute name
     * @see AbstractStructArrayBase::getAttributeName()
     * @return string RichiestaCartellino_Evento
     */
    public function getAttributeName()
    {
        return 'RichiestaCartellino_Evento';
    }
}
