<?php

namespace dgsoft\StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for VendorMessagesType StructType
 * @package Dg
 * @subpackage Structs
 */
class DgVendorMessagesType extends AbstractStructBase
{
    /**
     * The VendorMessage
     * Meta informations extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \dgsoft\StructType\DgVendorMessageType[]
     */
    public $VendorMessage;
    /**
     * Constructor method for VendorMessagesType
     * @uses DgVendorMessagesType::setVendorMessage()
     * @param \dgsoft\StructType\DgVendorMessageType[] $vendorMessage
     */
    public function __construct(array $vendorMessage = array())
    {
        $this
            ->setVendorMessage($vendorMessage);
    }
    /**
     * Get VendorMessage value
     * @return \dgsoft\StructType\DgVendorMessageType[]|null
     */
    public function getVendorMessage()
    {
        return $this->VendorMessage;
    }
    /**
     * Set VendorMessage value
     * @throws \InvalidArgumentException
     * @param \dgsoft\StructType\DgVendorMessageType[] $vendorMessage
     * @return \dgsoft\StructType\DgVendorMessagesType
     */
    public function setVendorMessage(array $vendorMessage = array())
    {
        foreach ($vendorMessage as $vendorMessagesTypeVendorMessageItem) {
            // validation for constraint: itemType
            if (!$vendorMessagesTypeVendorMessageItem instanceof \dgsoft\StructType\DgVendorMessageType) {
                throw new \InvalidArgumentException(sprintf('The VendorMessage property can only contain items of \dgsoft\StructType\DgVendorMessageType, "%s" given', is_object($vendorMessagesTypeVendorMessageItem) ? get_class($vendorMessagesTypeVendorMessageItem) : gettype($vendorMessagesTypeVendorMessageItem)), __LINE__);
            }
        }
        $this->VendorMessage = $vendorMessage;
        return $this;
    }
    /**
     * Add item to VendorMessage value
     * @throws \InvalidArgumentException
     * @param \dgsoft\StructType\DgVendorMessageType $item
     * @return \dgsoft\StructType\DgVendorMessagesType
     */
    public function addToVendorMessage(\dgsoft\StructType\DgVendorMessageType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \dgsoft\StructType\DgVendorMessageType) {
            throw new \InvalidArgumentException(sprintf('The VendorMessage property can only contain items of \dgsoft\StructType\DgVendorMessageType, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
        }
        $this->VendorMessage[] = $item;
        return $this;
    }
    /**
     * Method called when an object has been exported with var_export() functions
     * It allows to return an object instantiated with the values
     * @see AbstractStructBase::__set_state()
     * @uses AbstractStructBase::__set_state()
     * @param array $array the exported values
     * @return \dgsoft\StructType\DgVendorMessagesType
     */
    public static function __set_state(array $array)
    {
        return parent::__set_state($array);
    }
    /**
     * Method returning the class name
     * @return string __CLASS__
     */
    public function __toString()
    {
        return __CLASS__;
    }
}
