<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Expense_Rate_Table_Rule_Request_ReferencesType StructType
 * Meta information extracted from the WSDL
 * - documentation: Element containing reference instances for Expense Rate Table Rule
 * @subpackage Structs
 */
class Expense_Rate_Table_Rule_Request_ReferencesType extends AbstractStructBase
{
    /**
     * The Expense_Rate_Table_Rule_Reference
     * Meta information extracted from the WSDL
     * - documentation: Reference to an existing Expense Rate Table Rule
     * - maxOccurs: unbounded
     * @var \StructType\Condition_RuleObjectType[]
     */
    public $Expense_Rate_Table_Rule_Reference;
    /**
     * Constructor method for Expense_Rate_Table_Rule_Request_ReferencesType
     * @uses Expense_Rate_Table_Rule_Request_ReferencesType::setExpense_Rate_Table_Rule_Reference()
     * @param \StructType\Condition_RuleObjectType[] $expense_Rate_Table_Rule_Reference
     */
    public function __construct(array $expense_Rate_Table_Rule_Reference = array())
    {
        $this
            ->setExpense_Rate_Table_Rule_Reference($expense_Rate_Table_Rule_Reference);
    }
    /**
     * Get Expense_Rate_Table_Rule_Reference value
     * @return \StructType\Condition_RuleObjectType[]|null
     */
    public function getExpense_Rate_Table_Rule_Reference()
    {
        return $this->Expense_Rate_Table_Rule_Reference;
    }
    /**
     * This method is responsible for validating the values passed to the setExpense_Rate_Table_Rule_Reference method
     * This method is willingly generated in order to preserve the one-line inline validation within the setExpense_Rate_Table_Rule_Reference method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateExpense_Rate_Table_Rule_ReferenceForArrayConstraintsFromSetExpense_Rate_Table_Rule_Reference(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $expense_Rate_Table_Rule_Request_ReferencesTypeExpense_Rate_Table_Rule_ReferenceItem) {
            // validation for constraint: itemType
            if (!$expense_Rate_Table_Rule_Request_ReferencesTypeExpense_Rate_Table_Rule_ReferenceItem instanceof \StructType\Condition_RuleObjectType) {
                $invalidValues[] = is_object($expense_Rate_Table_Rule_Request_ReferencesTypeExpense_Rate_Table_Rule_ReferenceItem) ? get_class($expense_Rate_Table_Rule_Request_ReferencesTypeExpense_Rate_Table_Rule_ReferenceItem) : sprintf('%s(%s)', gettype($expense_Rate_Table_Rule_Request_ReferencesTypeExpense_Rate_Table_Rule_ReferenceItem), var_export($expense_Rate_Table_Rule_Request_ReferencesTypeExpense_Rate_Table_Rule_ReferenceItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Expense_Rate_Table_Rule_Reference property can only contain items of type \StructType\Condition_RuleObjectType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Expense_Rate_Table_Rule_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Condition_RuleObjectType[] $expense_Rate_Table_Rule_Reference
     * @return \StructType\Expense_Rate_Table_Rule_Request_ReferencesType
     */
    public function setExpense_Rate_Table_Rule_Reference(array $expense_Rate_Table_Rule_Reference = array())
    {
        // validation for constraint: array
        if ('' !== ($expense_Rate_Table_Rule_ReferenceArrayErrorMessage = self::validateExpense_Rate_Table_Rule_ReferenceForArrayConstraintsFromSetExpense_Rate_Table_Rule_Reference($expense_Rate_Table_Rule_Reference))) {
            throw new \InvalidArgumentException($expense_Rate_Table_Rule_ReferenceArrayErrorMessage, __LINE__);
        }
        $this->Expense_Rate_Table_Rule_Reference = $expense_Rate_Table_Rule_Reference;
        return $this;
    }
    /**
     * Add item to Expense_Rate_Table_Rule_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Condition_RuleObjectType $item
     * @return \StructType\Expense_Rate_Table_Rule_Request_ReferencesType
     */
    public function addToExpense_Rate_Table_Rule_Reference(\StructType\Condition_RuleObjectType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Condition_RuleObjectType) {
            throw new \InvalidArgumentException(sprintf('The Expense_Rate_Table_Rule_Reference property can only contain items of type \StructType\Condition_RuleObjectType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Expense_Rate_Table_Rule_Reference[] = $item;
        return $this;
    }
}
