<?php

namespace patest\ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

/**
 * This class stands for ArrayOfTicketing.PriceLevel ArrayType
 * Meta information extracted from the WSDL
 * - nillable: true
 * - type: tns:ArrayOfTicketing.PriceLevel
 * @subpackage Arrays
 */
class ArrayOfTicketing_PriceLevel extends AbstractStructArrayBase
{
    /**
     * The Ticketing_PriceLevel
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var \patest\StructType\Ticketing_PriceLevel[]
     */
    public $Ticketing_PriceLevel;
    /**
     * Constructor method for ArrayOfTicketing.PriceLevel
     * @uses ArrayOfTicketing_PriceLevel::setTicketing_PriceLevel()
     * @param \patest\StructType\Ticketing_PriceLevel[] $ticketing_PriceLevel
     */
    public function __construct(array $ticketing_PriceLevel = array())
    {
        $this
            ->setTicketing_PriceLevel($ticketing_PriceLevel);
    }
    /**
     * Get Ticketing_PriceLevel value
     * An additional test has been added (isset) before returning the property value as
     * this property may have been unset before, due to the fact that this property is
     * removable from the request (nillable=true+minOccurs=0)
     * @return \patest\StructType\Ticketing_PriceLevel[]|null
     */
    public function getTicketing_PriceLevel()
    {
        return isset($this->{'Ticketing.PriceLevel'}) ? $this->{'Ticketing.PriceLevel'} : null;
    }
    /**
     * This method is responsible for validating the values passed to the setTicketing_PriceLevel method
     * This method is willingly generated in order to preserve the one-line inline validation within the setTicketing_PriceLevel method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateTicketing_PriceLevelForArrayConstraintsFromSetTicketing_PriceLevel(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $arrayOfTicketing_PriceLevelTicketing_PriceLevelItem) {
            // validation for constraint: itemType
            if (!$arrayOfTicketing_PriceLevelTicketing_PriceLevelItem instanceof \patest\StructType\Ticketing_PriceLevel) {
                $invalidValues[] = is_object($arrayOfTicketing_PriceLevelTicketing_PriceLevelItem) ? get_class($arrayOfTicketing_PriceLevelTicketing_PriceLevelItem) : sprintf('%s(%s)', gettype($arrayOfTicketing_PriceLevelTicketing_PriceLevelItem), var_export($arrayOfTicketing_PriceLevelTicketing_PriceLevelItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Ticketing_PriceLevel property can only contain items of type \patest\StructType\Ticketing_PriceLevel, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Ticketing_PriceLevel value
     * This property is removable from request (nillable=true+minOccurs=0), therefore
     * if the value assigned to this property is null, it is removed from this object
     * @throws \InvalidArgumentException
     * @param \patest\StructType\Ticketing_PriceLevel[] $ticketing_PriceLevel
     * @return \patest\ArrayType\ArrayOfTicketing_PriceLevel
     */
    public function setTicketing_PriceLevel(array $ticketing_PriceLevel = array())
    {
        // validation for constraint: array
        if ('' !== ($ticketing_PriceLevelArrayErrorMessage = self::validateTicketing_PriceLevelForArrayConstraintsFromSetTicketing_PriceLevel($ticketing_PriceLevel))) {
            throw new \InvalidArgumentException($ticketing_PriceLevelArrayErrorMessage, __LINE__);
        }
        if (is_null($ticketing_PriceLevel) || (is_array($ticketing_PriceLevel) && empty($ticketing_PriceLevel))) {
            unset($this->Ticketing_PriceLevel, $this->{'Ticketing.PriceLevel'});
        } else {
            $this->Ticketing_PriceLevel = $this->{'Ticketing.PriceLevel'} = $ticketing_PriceLevel;
        }
        return $this;
    }
    /**
     * Add item to Ticketing_PriceLevel value
     * @throws \InvalidArgumentException
     * @param \patest\StructType\Ticketing_PriceLevel $item
     * @return \patest\ArrayType\ArrayOfTicketing_PriceLevel
     */
    public function addToTicketing_PriceLevel(\patest\StructType\Ticketing_PriceLevel $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \patest\StructType\Ticketing_PriceLevel) {
            throw new \InvalidArgumentException(sprintf('The Ticketing_PriceLevel property can only contain items of type \patest\StructType\Ticketing_PriceLevel, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Ticketing_PriceLevel[] = $this->{'Ticketing.PriceLevel'}[] = $item;
        return $this;
    }
    /**
     * Returns the current element
     * @see AbstractStructArrayBase::current()
     * @return \patest\StructType\Ticketing_PriceLevel|null
     */
    public function current()
    {
        return parent::current();
    }
    /**
     * Returns the indexed element
     * @see AbstractStructArrayBase::item()
     * @param int $index
     * @return \patest\StructType\Ticketing_PriceLevel|null
     */
    public function item($index)
    {
        return parent::item($index);
    }
    /**
     * Returns the first element
     * @see AbstractStructArrayBase::first()
     * @return \patest\StructType\Ticketing_PriceLevel|null
     */
    public function first()
    {
        return parent::first();
    }
    /**
     * Returns the last element
     * @see AbstractStructArrayBase::last()
     * @return \patest\StructType\Ticketing_PriceLevel|null
     */
    public function last()
    {
        return parent::last();
    }
    /**
     * Returns the element at the offset
     * @see AbstractStructArrayBase::offsetGet()
     * @param int $offset
     * @return \patest\StructType\Ticketing_PriceLevel|null
     */
    public function offsetGet($offset)
    {
        return parent::offsetGet($offset);
    }
    /**
     * Returns the attribute name
     * @see AbstractStructArrayBase::getAttributeName()
     * @return string Ticketing.PriceLevel
     */
    public function getAttributeName()
    {
        return 'Ticketing.PriceLevel';
    }
}
