<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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