<?php
use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for members StructType
 * Meta informations extracted from the WSDL
 * - documentation: On Addition always the first member added is itself. Do not specify the first member as itself in an Add request . Also make sure that the priority always starts with 1. It will internally be taken care of during Addition and
 * Updation. | On Addition always the first member added is itself. Do not specify the first member as itself in an Add request . Also make sure that the priority always starts with 1. It will internally be taken care of during Addition and Updation.
 * @subpackage Structs
 */
class Members extends XCommonMembersExtension
{
    /**
     * The member
     * Meta informations extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var XTimeScheduleTimePeriod[]
     */
    public $member;
    /**
     * Constructor method for members
     * @uses Members::setMember()
     * @param XTimeScheduleTimePeriod[] $member
     */
    public function __construct(array $member = array())
    {
        $this
            ->setMember($member);
    }
    /**
     * Get member value
     * @return XTimeScheduleTimePeriod[]|null
     */
    public function getMember()
    {
        return $this->member;
    }
    /**
     * Set member value
     * @throws \InvalidArgumentException
     * @param XTimeScheduleTimePeriod[] $member
     * @return Members
     */
    public function setMember(array $member = array())
    {
        foreach ($member as $membersMemberItem) {
            // validation for constraint: itemType
            if (!$membersMemberItem instanceof XTimeScheduleTimePeriod) {
                throw new \InvalidArgumentException(sprintf('The member property can only contain items of XTimeScheduleTimePeriod, "%s" given', is_object($membersMemberItem) ? get_class($membersMemberItem) : gettype($membersMemberItem)), __LINE__);
            }
        }
        $this->member = $member;
        return $this;
    }
    /**
     * Add item to member value
     * @throws \InvalidArgumentException
     * @param XTimeScheduleTimePeriod $item
     * @return Members
     */
    public function addToMember(XTimeScheduleTimePeriod $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof XTimeScheduleTimePeriod) {
            throw new \InvalidArgumentException(sprintf('The member property can only contain items of XTimeScheduleTimePeriod, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
        }
        $this->member[] = $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 Members
     */
    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__;
    }
}
