<?php

namespace patest\ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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