<?php

namespace ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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