<?php

namespace GQ_\Structs;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for ExceptionInformation.Exceptions Structs
 * Meta information extracted from the WSDL
 * - nillable: true
 * - type: tns:ExceptionInformation.Exceptions
 * @package GQ_
 * @subpackage Structs
 */
class GQ_ExceptionInformation_Exceptions extends AbstractStructBase
{
    /**
     * The ExceptionInformation_Exception
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var \GQ_\Structs\GQ_ExceptionInformation_Exception[]
     */
    public $ExceptionInformation_Exception;
    /**
     * Constructor method for ExceptionInformation.Exceptions
     * @uses GQ_ExceptionInformation_Exceptions::setExceptionInformation_Exception()
     * @param \GQ_\Structs\GQ_ExceptionInformation_Exception[] $exceptionInformation_Exception
     */
    public function __construct(array $exceptionInformation_Exception = array())
    {
        $this
            ->setExceptionInformation_Exception($exceptionInformation_Exception);
    }
    /**
     * Get ExceptionInformation_Exception 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 \GQ_\Structs\GQ_ExceptionInformation_Exception[]|null
     */
    public function getExceptionInformation_Exception()
    {
        return isset($this->{'ExceptionInformation.Exception'}) ? $this->{'ExceptionInformation.Exception'} : null;
    }
    /**
     * This method is responsible for validating the values passed to the setExceptionInformation_Exception method
     * This method is willingly generated in order to preserve the one-line inline validation within the setExceptionInformation_Exception method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateExceptionInformation_ExceptionForArrayConstraintsFromSetExceptionInformation_Exception(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $exceptionInformation_ExceptionsExceptionInformation_ExceptionItem) {
            // validation for constraint: itemType
            if (!$exceptionInformation_ExceptionsExceptionInformation_ExceptionItem instanceof \GQ_\Structs\GQ_ExceptionInformation_Exception) {
                $invalidValues[] = is_object($exceptionInformation_ExceptionsExceptionInformation_ExceptionItem) ? get_class($exceptionInformation_ExceptionsExceptionInformation_ExceptionItem) : sprintf('%s(%s)', gettype($exceptionInformation_ExceptionsExceptionInformation_ExceptionItem), var_export($exceptionInformation_ExceptionsExceptionInformation_ExceptionItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The ExceptionInformation_Exception property can only contain items of type \GQ_\Structs\GQ_ExceptionInformation_Exception, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set ExceptionInformation_Exception 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 \GQ_\Structs\GQ_ExceptionInformation_Exception[] $exceptionInformation_Exception
     * @return \GQ_\Structs\GQ_ExceptionInformation_Exceptions
     */
    public function setExceptionInformation_Exception(array $exceptionInformation_Exception = array())
    {
        // validation for constraint: array
        if ('' !== ($exceptionInformation_ExceptionArrayErrorMessage = self::validateExceptionInformation_ExceptionForArrayConstraintsFromSetExceptionInformation_Exception($exceptionInformation_Exception))) {
            throw new \InvalidArgumentException($exceptionInformation_ExceptionArrayErrorMessage, __LINE__);
        }
        if (is_null($exceptionInformation_Exception) || (is_array($exceptionInformation_Exception) && empty($exceptionInformation_Exception))) {
            unset($this->ExceptionInformation_Exception, $this->{'ExceptionInformation.Exception'});
        } else {
            $this->ExceptionInformation_Exception = $this->{'ExceptionInformation.Exception'} = $exceptionInformation_Exception;
        }
        return $this;
    }
    /**
     * Add item to ExceptionInformation_Exception value
     * @throws \InvalidArgumentException
     * @param \GQ_\Structs\GQ_ExceptionInformation_Exception $item
     * @return \GQ_\Structs\GQ_ExceptionInformation_Exceptions
     */
    public function addToExceptionInformation_Exception(\GQ_\Structs\GQ_ExceptionInformation_Exception $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \GQ_\Structs\GQ_ExceptionInformation_Exception) {
            throw new \InvalidArgumentException(sprintf('The ExceptionInformation_Exception property can only contain items of type \GQ_\Structs\GQ_ExceptionInformation_Exception, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->ExceptionInformation_Exception[] = $this->{'ExceptionInformation.Exception'}[] = $item;
        return $this;
    }
}
