<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for PeriodDemandPlanList StructType
 * @subpackage Structs
 */
class PeriodDemandPlanList extends AbstractStructBase
{
    /**
     * The periodDemandPlan
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\PeriodDemandPlan[]
     */
    public $periodDemandPlan;
    /**
     * Constructor method for PeriodDemandPlanList
     * @uses PeriodDemandPlanList::setPeriodDemandPlan()
     * @param \StructType\PeriodDemandPlan[] $periodDemandPlan
     */
    public function __construct(array $periodDemandPlan = array())
    {
        $this
            ->setPeriodDemandPlan($periodDemandPlan);
    }
    /**
     * Get periodDemandPlan value
     * @return \StructType\PeriodDemandPlan[]|null
     */
    public function getPeriodDemandPlan()
    {
        return $this->periodDemandPlan;
    }
    /**
     * This method is responsible for validating the values passed to the setPeriodDemandPlan method
     * This method is willingly generated in order to preserve the one-line inline validation within the setPeriodDemandPlan method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validatePeriodDemandPlanForArrayConstraintsFromSetPeriodDemandPlan(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $periodDemandPlanListPeriodDemandPlanItem) {
            // validation for constraint: itemType
            if (!$periodDemandPlanListPeriodDemandPlanItem instanceof \StructType\PeriodDemandPlan) {
                $invalidValues[] = is_object($periodDemandPlanListPeriodDemandPlanItem) ? get_class($periodDemandPlanListPeriodDemandPlanItem) : sprintf('%s(%s)', gettype($periodDemandPlanListPeriodDemandPlanItem), var_export($periodDemandPlanListPeriodDemandPlanItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The periodDemandPlan property can only contain items of type \StructType\PeriodDemandPlan, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set periodDemandPlan value
     * @throws \InvalidArgumentException
     * @param \StructType\PeriodDemandPlan[] $periodDemandPlan
     * @return \StructType\PeriodDemandPlanList
     */
    public function setPeriodDemandPlan(array $periodDemandPlan = array())
    {
        // validation for constraint: array
        if ('' !== ($periodDemandPlanArrayErrorMessage = self::validatePeriodDemandPlanForArrayConstraintsFromSetPeriodDemandPlan($periodDemandPlan))) {
            throw new \InvalidArgumentException($periodDemandPlanArrayErrorMessage, __LINE__);
        }
        $this->periodDemandPlan = $periodDemandPlan;
        return $this;
    }
    /**
     * Add item to periodDemandPlan value
     * @throws \InvalidArgumentException
     * @param \StructType\PeriodDemandPlan $item
     * @return \StructType\PeriodDemandPlanList
     */
    public function addToPeriodDemandPlan(\StructType\PeriodDemandPlan $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\PeriodDemandPlan) {
            throw new \InvalidArgumentException(sprintf('The periodDemandPlan property can only contain items of type \StructType\PeriodDemandPlan, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->periodDemandPlan[] = $item;
        return $this;
    }
}
