<?php

namespace dgsoft\StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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