<?php

namespace dgsoft\StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for AncillaryProductsType StructType
 * @package Dg
 * @subpackage Structs
 */
class DgAncillaryProductsType extends AbstractStructBase
{
    /**
     * The AncillaryProduct
     * Meta informations extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \dgsoft\StructType\DgAncillaryProductType[]
     */
    public $AncillaryProduct;
    /**
     * Constructor method for AncillaryProductsType
     * @uses DgAncillaryProductsType::setAncillaryProduct()
     * @param \dgsoft\StructType\DgAncillaryProductType[] $ancillaryProduct
     */
    public function __construct(array $ancillaryProduct = array())
    {
        $this
            ->setAncillaryProduct($ancillaryProduct);
    }
    /**
     * Get AncillaryProduct value
     * @return \dgsoft\StructType\DgAncillaryProductType[]|null
     */
    public function getAncillaryProduct()
    {
        return $this->AncillaryProduct;
    }
    /**
     * Set AncillaryProduct value
     * @throws \InvalidArgumentException
     * @param \dgsoft\StructType\DgAncillaryProductType[] $ancillaryProduct
     * @return \dgsoft\StructType\DgAncillaryProductsType
     */
    public function setAncillaryProduct(array $ancillaryProduct = array())
    {
        foreach ($ancillaryProduct as $ancillaryProductsTypeAncillaryProductItem) {
            // validation for constraint: itemType
            if (!$ancillaryProductsTypeAncillaryProductItem instanceof \dgsoft\StructType\DgAncillaryProductType) {
                throw new \InvalidArgumentException(sprintf('The AncillaryProduct property can only contain items of \dgsoft\StructType\DgAncillaryProductType, "%s" given', is_object($ancillaryProductsTypeAncillaryProductItem) ? get_class($ancillaryProductsTypeAncillaryProductItem) : gettype($ancillaryProductsTypeAncillaryProductItem)), __LINE__);
            }
        }
        $this->AncillaryProduct = $ancillaryProduct;
        return $this;
    }
    /**
     * Add item to AncillaryProduct value
     * @throws \InvalidArgumentException
     * @param \dgsoft\StructType\DgAncillaryProductType $item
     * @return \dgsoft\StructType\DgAncillaryProductsType
     */
    public function addToAncillaryProduct(\dgsoft\StructType\DgAncillaryProductType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \dgsoft\StructType\DgAncillaryProductType) {
            throw new \InvalidArgumentException(sprintf('The AncillaryProduct property can only contain items of \dgsoft\StructType\DgAncillaryProductType, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
        }
        $this->AncillaryProduct[] = $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\DgAncillaryProductsType
     */
    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__;
    }
}
