<?php

namespace patest\ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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