<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for JourneyPatterns StructType
 * Meta informations extracted from the WSDL
 * - documentation: JourneyPatterns in Direction of route (+SIRI 2.0)
 * @subpackage Structs
 */
class JourneyPatterns extends AbstractStructBase
{
    /**
     * The JourneyPattern
     * Meta informations extracted from the WSDL
     * - maxOccurs: unbounded
     * @var \StructType\JourneyPattern[]
     */
    public $JourneyPattern;
    /**
     * Constructor method for JourneyPatterns
     * @uses JourneyPatterns::setJourneyPattern()
     * @param \StructType\JourneyPattern[] $journeyPattern
     */
    public function __construct(array $journeyPattern = array())
    {
        $this
            ->setJourneyPattern($journeyPattern);
    }
    /**
     * Get JourneyPattern value
     * @return \StructType\JourneyPattern[]|null
     */
    public function getJourneyPattern()
    {
        return $this->JourneyPattern;
    }
    /**
     * Set JourneyPattern value
     * @throws \InvalidArgumentException
     * @param \StructType\JourneyPattern[] $journeyPattern
     * @return \StructType\JourneyPatterns
     */
    public function setJourneyPattern(array $journeyPattern = array())
    {
        foreach ($journeyPattern as $journeyPatternsJourneyPatternItem) {
            // validation for constraint: itemType
            if (!$journeyPatternsJourneyPatternItem instanceof \StructType\JourneyPattern) {
                throw new \InvalidArgumentException(sprintf('The JourneyPattern property can only contain items of \StructType\JourneyPattern, "%s" given', is_object($journeyPatternsJourneyPatternItem) ? get_class($journeyPatternsJourneyPatternItem) : gettype($journeyPatternsJourneyPatternItem)), __LINE__);
            }
        }
        $this->JourneyPattern = $journeyPattern;
        return $this;
    }
    /**
     * Add item to JourneyPattern value
     * @throws \InvalidArgumentException
     * @param \StructType\JourneyPattern $item
     * @return \StructType\JourneyPatterns
     */
    public function addToJourneyPattern(\StructType\JourneyPattern $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\JourneyPattern) {
            throw new \InvalidArgumentException(sprintf('The JourneyPattern property can only contain items of \StructType\JourneyPattern, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
        }
        $this->JourneyPattern[] = $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 \StructType\JourneyPatterns
     */
    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__;
    }
}
