<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Expense_Rate_Table_Rule_Response_DataType StructType
 * Meta information extracted from the WSDL
 * - documentation: Wrapper Element that includes Expense Rate Table Rule Instance and Data
 * @subpackage Structs
 */
class Expense_Rate_Table_Rule_Response_DataType extends AbstractStructBase
{
    /**
     * The Expense_Rate_Table_Rule
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\Expense_Rate_Table_RuleType[]
     */
    public $Expense_Rate_Table_Rule;
    /**
     * Constructor method for Expense_Rate_Table_Rule_Response_DataType
     * @uses Expense_Rate_Table_Rule_Response_DataType::setExpense_Rate_Table_Rule()
     * @param \StructType\Expense_Rate_Table_RuleType[] $expense_Rate_Table_Rule
     */
    public function __construct(array $expense_Rate_Table_Rule = array())
    {
        $this
            ->setExpense_Rate_Table_Rule($expense_Rate_Table_Rule);
    }
    /**
     * Get Expense_Rate_Table_Rule value
     * @return \StructType\Expense_Rate_Table_RuleType[]|null
     */
    public function getExpense_Rate_Table_Rule()
    {
        return $this->Expense_Rate_Table_Rule;
    }
    /**
     * This method is responsible for validating the values passed to the setExpense_Rate_Table_Rule method
     * This method is willingly generated in order to preserve the one-line inline validation within the setExpense_Rate_Table_Rule 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_RuleForArrayConstraintsFromSetExpense_Rate_Table_Rule(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $expense_Rate_Table_Rule_Response_DataTypeExpense_Rate_Table_RuleItem) {
            // validation for constraint: itemType
            if (!$expense_Rate_Table_Rule_Response_DataTypeExpense_Rate_Table_RuleItem instanceof \StructType\Expense_Rate_Table_RuleType) {
                $invalidValues[] = is_object($expense_Rate_Table_Rule_Response_DataTypeExpense_Rate_Table_RuleItem) ? get_class($expense_Rate_Table_Rule_Response_DataTypeExpense_Rate_Table_RuleItem) : sprintf('%s(%s)', gettype($expense_Rate_Table_Rule_Response_DataTypeExpense_Rate_Table_RuleItem), var_export($expense_Rate_Table_Rule_Response_DataTypeExpense_Rate_Table_RuleItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Expense_Rate_Table_Rule property can only contain items of type \StructType\Expense_Rate_Table_RuleType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Expense_Rate_Table_Rule value
     * @throws \InvalidArgumentException
     * @param \StructType\Expense_Rate_Table_RuleType[] $expense_Rate_Table_Rule
     * @return \StructType\Expense_Rate_Table_Rule_Response_DataType
     */
    public function setExpense_Rate_Table_Rule(array $expense_Rate_Table_Rule = array())
    {
        // validation for constraint: array
        if ('' !== ($expense_Rate_Table_RuleArrayErrorMessage = self::validateExpense_Rate_Table_RuleForArrayConstraintsFromSetExpense_Rate_Table_Rule($expense_Rate_Table_Rule))) {
            throw new \InvalidArgumentException($expense_Rate_Table_RuleArrayErrorMessage, __LINE__);
        }
        $this->Expense_Rate_Table_Rule = $expense_Rate_Table_Rule;
        return $this;
    }
    /**
     * Add item to Expense_Rate_Table_Rule value
     * @throws \InvalidArgumentException
     * @param \StructType\Expense_Rate_Table_RuleType $item
     * @return \StructType\Expense_Rate_Table_Rule_Response_DataType
     */
    public function addToExpense_Rate_Table_Rule(\StructType\Expense_Rate_Table_RuleType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Expense_Rate_Table_RuleType) {
            throw new \InvalidArgumentException(sprintf('The Expense_Rate_Table_Rule property can only contain items of type \StructType\Expense_Rate_Table_RuleType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Expense_Rate_Table_Rule[] = $item;
        return $this;
    }
}
