<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for BudgetExchangeRateList StructType
 * @subpackage Structs
 */
class BudgetExchangeRateList extends AbstractStructBase
{
    /**
     * The budgetExchangeRate
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * @var \StructType\BudgetExchangeRate[]
     */
    public $budgetExchangeRate;
    /**
     * Constructor method for BudgetExchangeRateList
     * @uses BudgetExchangeRateList::setBudgetExchangeRate()
     * @param \StructType\BudgetExchangeRate[] $budgetExchangeRate
     */
    public function __construct(array $budgetExchangeRate = array())
    {
        $this
            ->setBudgetExchangeRate($budgetExchangeRate);
    }
    /**
     * Get budgetExchangeRate value
     * @return \StructType\BudgetExchangeRate[]|null
     */
    public function getBudgetExchangeRate()
    {
        return $this->budgetExchangeRate;
    }
    /**
     * This method is responsible for validating the values passed to the setBudgetExchangeRate method
     * This method is willingly generated in order to preserve the one-line inline validation within the setBudgetExchangeRate method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateBudgetExchangeRateForArrayConstraintsFromSetBudgetExchangeRate(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $budgetExchangeRateListBudgetExchangeRateItem) {
            // validation for constraint: itemType
            if (!$budgetExchangeRateListBudgetExchangeRateItem instanceof \StructType\BudgetExchangeRate) {
                $invalidValues[] = is_object($budgetExchangeRateListBudgetExchangeRateItem) ? get_class($budgetExchangeRateListBudgetExchangeRateItem) : sprintf('%s(%s)', gettype($budgetExchangeRateListBudgetExchangeRateItem), var_export($budgetExchangeRateListBudgetExchangeRateItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The budgetExchangeRate property can only contain items of type \StructType\BudgetExchangeRate, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set budgetExchangeRate value
     * @throws \InvalidArgumentException
     * @param \StructType\BudgetExchangeRate[] $budgetExchangeRate
     * @return \StructType\BudgetExchangeRateList
     */
    public function setBudgetExchangeRate(array $budgetExchangeRate = array())
    {
        // validation for constraint: array
        if ('' !== ($budgetExchangeRateArrayErrorMessage = self::validateBudgetExchangeRateForArrayConstraintsFromSetBudgetExchangeRate($budgetExchangeRate))) {
            throw new \InvalidArgumentException($budgetExchangeRateArrayErrorMessage, __LINE__);
        }
        $this->budgetExchangeRate = $budgetExchangeRate;
        return $this;
    }
    /**
     * Add item to budgetExchangeRate value
     * @throws \InvalidArgumentException
     * @param \StructType\BudgetExchangeRate $item
     * @return \StructType\BudgetExchangeRateList
     */
    public function addToBudgetExchangeRate(\StructType\BudgetExchangeRate $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\BudgetExchangeRate) {
            throw new \InvalidArgumentException(sprintf('The budgetExchangeRate property can only contain items of type \StructType\BudgetExchangeRate, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->budgetExchangeRate[] = $item;
        return $this;
    }
}
