<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for External_Reference_Response_DataType StructType
 * Meta information extracted from the WSDL
 * - documentation: The successfully added or updated external reference.
 * @subpackage Structs
 */
class External_Reference_Response_DataType extends AbstractStructBase
{
    /**
     * The External_Reference
     * Meta information extracted from the WSDL
     * - documentation: The External Reference.
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\External_ReferenceType[]
     */
    public $External_Reference;
    /**
     * Constructor method for External_Reference_Response_DataType
     * @uses External_Reference_Response_DataType::setExternal_Reference()
     * @param \StructType\External_ReferenceType[] $external_Reference
     */
    public function __construct(array $external_Reference = array())
    {
        $this
            ->setExternal_Reference($external_Reference);
    }
    /**
     * Get External_Reference value
     * @return \StructType\External_ReferenceType[]|null
     */
    public function getExternal_Reference()
    {
        return $this->External_Reference;
    }
    /**
     * This method is responsible for validating the values passed to the setExternal_Reference method
     * This method is willingly generated in order to preserve the one-line inline validation within the setExternal_Reference method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateExternal_ReferenceForArrayConstraintsFromSetExternal_Reference(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $external_Reference_Response_DataTypeExternal_ReferenceItem) {
            // validation for constraint: itemType
            if (!$external_Reference_Response_DataTypeExternal_ReferenceItem instanceof \StructType\External_ReferenceType) {
                $invalidValues[] = is_object($external_Reference_Response_DataTypeExternal_ReferenceItem) ? get_class($external_Reference_Response_DataTypeExternal_ReferenceItem) : sprintf('%s(%s)', gettype($external_Reference_Response_DataTypeExternal_ReferenceItem), var_export($external_Reference_Response_DataTypeExternal_ReferenceItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The External_Reference property can only contain items of type \StructType\External_ReferenceType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set External_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\External_ReferenceType[] $external_Reference
     * @return \StructType\External_Reference_Response_DataType
     */
    public function setExternal_Reference(array $external_Reference = array())
    {
        // validation for constraint: array
        if ('' !== ($external_ReferenceArrayErrorMessage = self::validateExternal_ReferenceForArrayConstraintsFromSetExternal_Reference($external_Reference))) {
            throw new \InvalidArgumentException($external_ReferenceArrayErrorMessage, __LINE__);
        }
        $this->External_Reference = $external_Reference;
        return $this;
    }
    /**
     * Add item to External_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\External_ReferenceType $item
     * @return \StructType\External_Reference_Response_DataType
     */
    public function addToExternal_Reference(\StructType\External_ReferenceType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\External_ReferenceType) {
            throw new \InvalidArgumentException(sprintf('The External_Reference property can only contain items of type \StructType\External_ReferenceType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->External_Reference[] = $item;
        return $this;
    }
}
