<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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