<?php

namespace ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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