<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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