<?php

namespace ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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