<?php

namespace dgsoft\StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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