<?php

namespace dgsoft\StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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