<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Spend_Category_Hierarchy_Response_DataType StructType
 * Meta information extracted from the WSDL
 * - documentation: Wrapper Element that includes Spend Category Hierarchy Instance and Data
 * @subpackage Structs
 */
class Spend_Category_Hierarchy_Response_DataType extends AbstractStructBase
{
    /**
     * The Spend_Category_Hierarchy
     * Meta information extracted from the WSDL
     * - documentation: Spend Category Hierarchy
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\Spend_Category_HierarchyType[]
     */
    public $Spend_Category_Hierarchy;
    /**
     * Constructor method for Spend_Category_Hierarchy_Response_DataType
     * @uses Spend_Category_Hierarchy_Response_DataType::setSpend_Category_Hierarchy()
     * @param \StructType\Spend_Category_HierarchyType[] $spend_Category_Hierarchy
     */
    public function __construct(array $spend_Category_Hierarchy = array())
    {
        $this
            ->setSpend_Category_Hierarchy($spend_Category_Hierarchy);
    }
    /**
     * Get Spend_Category_Hierarchy value
     * @return \StructType\Spend_Category_HierarchyType[]|null
     */
    public function getSpend_Category_Hierarchy()
    {
        return $this->Spend_Category_Hierarchy;
    }
    /**
     * This method is responsible for validating the values passed to the setSpend_Category_Hierarchy method
     * This method is willingly generated in order to preserve the one-line inline validation within the setSpend_Category_Hierarchy method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateSpend_Category_HierarchyForArrayConstraintsFromSetSpend_Category_Hierarchy(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $spend_Category_Hierarchy_Response_DataTypeSpend_Category_HierarchyItem) {
            // validation for constraint: itemType
            if (!$spend_Category_Hierarchy_Response_DataTypeSpend_Category_HierarchyItem instanceof \StructType\Spend_Category_HierarchyType) {
                $invalidValues[] = is_object($spend_Category_Hierarchy_Response_DataTypeSpend_Category_HierarchyItem) ? get_class($spend_Category_Hierarchy_Response_DataTypeSpend_Category_HierarchyItem) : sprintf('%s(%s)', gettype($spend_Category_Hierarchy_Response_DataTypeSpend_Category_HierarchyItem), var_export($spend_Category_Hierarchy_Response_DataTypeSpend_Category_HierarchyItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Spend_Category_Hierarchy property can only contain items of type \StructType\Spend_Category_HierarchyType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Spend_Category_Hierarchy value
     * @throws \InvalidArgumentException
     * @param \StructType\Spend_Category_HierarchyType[] $spend_Category_Hierarchy
     * @return \StructType\Spend_Category_Hierarchy_Response_DataType
     */
    public function setSpend_Category_Hierarchy(array $spend_Category_Hierarchy = array())
    {
        // validation for constraint: array
        if ('' !== ($spend_Category_HierarchyArrayErrorMessage = self::validateSpend_Category_HierarchyForArrayConstraintsFromSetSpend_Category_Hierarchy($spend_Category_Hierarchy))) {
            throw new \InvalidArgumentException($spend_Category_HierarchyArrayErrorMessage, __LINE__);
        }
        $this->Spend_Category_Hierarchy = $spend_Category_Hierarchy;
        return $this;
    }
    /**
     * Add item to Spend_Category_Hierarchy value
     * @throws \InvalidArgumentException
     * @param \StructType\Spend_Category_HierarchyType $item
     * @return \StructType\Spend_Category_Hierarchy_Response_DataType
     */
    public function addToSpend_Category_Hierarchy(\StructType\Spend_Category_HierarchyType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Spend_Category_HierarchyType) {
            throw new \InvalidArgumentException(sprintf('The Spend_Category_Hierarchy property can only contain items of type \StructType\Spend_Category_HierarchyType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Spend_Category_Hierarchy[] = $item;
        return $this;
    }
}
