<?php
use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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