<?php
use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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