<?php

namespace ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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