<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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