<?php
use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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