<?php

namespace patest\ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

/**
 * This class stands for ArrayOfTicketFooterNote ArrayType
 * Meta information extracted from the WSDL
 * - nillable: true
 * - type: tns:ArrayOfTicketFooterNote
 * @subpackage Arrays
 */
class ArrayOfTicketFooterNote extends AbstractStructArrayBase
{
    /**
     * The TicketFooterNote
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var \patest\StructType\TicketFooterNote[]
     */
    public $TicketFooterNote;
    /**
     * Constructor method for ArrayOfTicketFooterNote
     * @uses ArrayOfTicketFooterNote::setTicketFooterNote()
     * @param \patest\StructType\TicketFooterNote[] $ticketFooterNote
     */
    public function __construct(array $ticketFooterNote = array())
    {
        $this
            ->setTicketFooterNote($ticketFooterNote);
    }
    /**
     * Get TicketFooterNote 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\TicketFooterNote[]|null
     */
    public function getTicketFooterNote()
    {
        return isset($this->TicketFooterNote) ? $this->TicketFooterNote : null;
    }
    /**
     * This method is responsible for validating the values passed to the setTicketFooterNote method
     * This method is willingly generated in order to preserve the one-line inline validation within the setTicketFooterNote method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateTicketFooterNoteForArrayConstraintsFromSetTicketFooterNote(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $arrayOfTicketFooterNoteTicketFooterNoteItem) {
            // validation for constraint: itemType
            if (!$arrayOfTicketFooterNoteTicketFooterNoteItem instanceof \patest\StructType\TicketFooterNote) {
                $invalidValues[] = is_object($arrayOfTicketFooterNoteTicketFooterNoteItem) ? get_class($arrayOfTicketFooterNoteTicketFooterNoteItem) : sprintf('%s(%s)', gettype($arrayOfTicketFooterNoteTicketFooterNoteItem), var_export($arrayOfTicketFooterNoteTicketFooterNoteItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The TicketFooterNote property can only contain items of type \patest\StructType\TicketFooterNote, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set TicketFooterNote 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\TicketFooterNote[] $ticketFooterNote
     * @return \patest\ArrayType\ArrayOfTicketFooterNote
     */
    public function setTicketFooterNote(array $ticketFooterNote = array())
    {
        // validation for constraint: array
        if ('' !== ($ticketFooterNoteArrayErrorMessage = self::validateTicketFooterNoteForArrayConstraintsFromSetTicketFooterNote($ticketFooterNote))) {
            throw new \InvalidArgumentException($ticketFooterNoteArrayErrorMessage, __LINE__);
        }
        if (is_null($ticketFooterNote) || (is_array($ticketFooterNote) && empty($ticketFooterNote))) {
            unset($this->TicketFooterNote);
        } else {
            $this->TicketFooterNote = $ticketFooterNote;
        }
        return $this;
    }
    /**
     * Add item to TicketFooterNote value
     * @throws \InvalidArgumentException
     * @param \patest\StructType\TicketFooterNote $item
     * @return \patest\ArrayType\ArrayOfTicketFooterNote
     */
    public function addToTicketFooterNote(\patest\StructType\TicketFooterNote $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \patest\StructType\TicketFooterNote) {
            throw new \InvalidArgumentException(sprintf('The TicketFooterNote property can only contain items of type \patest\StructType\TicketFooterNote, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->TicketFooterNote[] = $item;
        return $this;
    }
    /**
     * Returns the current element
     * @see AbstractStructArrayBase::current()
     * @return \patest\StructType\TicketFooterNote|null
     */
    public function current()
    {
        return parent::current();
    }
    /**
     * Returns the indexed element
     * @see AbstractStructArrayBase::item()
     * @param int $index
     * @return \patest\StructType\TicketFooterNote|null
     */
    public function item($index)
    {
        return parent::item($index);
    }
    /**
     * Returns the first element
     * @see AbstractStructArrayBase::first()
     * @return \patest\StructType\TicketFooterNote|null
     */
    public function first()
    {
        return parent::first();
    }
    /**
     * Returns the last element
     * @see AbstractStructArrayBase::last()
     * @return \patest\StructType\TicketFooterNote|null
     */
    public function last()
    {
        return parent::last();
    }
    /**
     * Returns the element at the offset
     * @see AbstractStructArrayBase::offsetGet()
     * @param int $offset
     * @return \patest\StructType\TicketFooterNote|null
     */
    public function offsetGet($offset)
    {
        return parent::offsetGet($offset);
    }
    /**
     * Returns the attribute name
     * @see AbstractStructArrayBase::getAttributeName()
     * @return string TicketFooterNote
     */
    public function getAttributeName()
    {
        return 'TicketFooterNote';
    }
}
