<?php

namespace patest\ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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