<?php

namespace ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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