<?php

namespace ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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