<?php

namespace ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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