<?php
use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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