<?php

namespace CustomerManagement\ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

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