<?php

declare(strict_types=1);

namespace Drupal\netforum\xWeb\Generated\ArrayType;

use InvalidArgumentException;
use WsdlToPhp\PackageBase\AbstractStructArrayBase;

/**
 * This class stands for ArrayOfAVWizardForm ArrayType
 * @subpackage Arrays
 * @author Drupal NetForum xWeb PHP SDK Generator
 * @version 1.0.0
 * @license GPL-2.0-or-later https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @see https://www.drupal.org/project/netforum
 * @generatedDate 2025-08-05
 * @generatedRelease Official
 * @generatedNetForumVersion 37
 */
class ArrayOfAVWizardForm extends AbstractStructArrayBase
{
    /**
     * The AVWizardForm
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm[]|null
     */
    protected ?array $AVWizardForm = null;
    /**
     * Constructor method for ArrayOfAVWizardForm
     * @uses ArrayOfAVWizardForm::setAVWizardForm()
     * @param \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm[] $aVWizardForm
     */
    public function __construct(?array $aVWizardForm = null)
    {
        $this
            ->setAVWizardForm($aVWizardForm);
    }
    /**
     * Get AVWizardForm 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 \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm[]|null
     */
    public function getAVWizardForm(): ?array
    {
        return $this->AVWizardForm ?? null;
    }
    /**
     * This method is responsible for validating the value(s) passed to the setAVWizardForm method
     * This method is willingly generated in order to preserve the one-line inline validation within the setAVWizardForm method
     * This has to validate that each item contained by the array match the itemType constraint
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateAVWizardFormForArrayConstraintFromSetAVWizardForm(?array $values = []): string
    {
        if (!is_array($values)) {
            return '';
        }
        $message = '';
        $invalidValues = [];
        foreach ($values as $arrayOfAVWizardFormAVWizardFormItem) {
            // validation for constraint: itemType
            if (!$arrayOfAVWizardFormAVWizardFormItem instanceof \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm) {
                $invalidValues[] = is_object($arrayOfAVWizardFormAVWizardFormItem) ? get_class($arrayOfAVWizardFormAVWizardFormItem) : sprintf('%s(%s)', gettype($arrayOfAVWizardFormAVWizardFormItem), var_export($arrayOfAVWizardFormAVWizardFormItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The AVWizardForm property can only contain items of type \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        
        return $message;
    }
    /**
     * Set AVWizardForm 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 \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm[] $aVWizardForm
     * @return \Drupal\netforum\xWeb\Generated\ArrayType\ArrayOfAVWizardForm
     */
    public function setAVWizardForm(?array $aVWizardForm = null): self
    {
        // validation for constraint: array
        if ('' !== ($aVWizardFormArrayErrorMessage = self::validateAVWizardFormForArrayConstraintFromSetAVWizardForm($aVWizardForm))) {
            throw new InvalidArgumentException($aVWizardFormArrayErrorMessage, __LINE__);
        }
        if (is_null($aVWizardForm) || (is_array($aVWizardForm) && empty($aVWizardForm))) {
            unset($this->AVWizardForm);
        } else {
            $this->AVWizardForm = $aVWizardForm;
        }
        
        return $this;
    }
    /**
     * Returns the current element
     * @see AbstractStructArrayBase::current()
     * @return \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm|null
     */
    public function current(): ?\Drupal\netforum\xWeb\Generated\StructType\AVWizardForm
    {
        return parent::current();
    }
    /**
     * Returns the indexed element
     * @see AbstractStructArrayBase::item()
     * @param int $index
     * @return \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm|null
     */
    public function item($index): ?\Drupal\netforum\xWeb\Generated\StructType\AVWizardForm
    {
        return parent::item($index);
    }
    /**
     * Returns the first element
     * @see AbstractStructArrayBase::first()
     * @return \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm|null
     */
    public function first(): ?\Drupal\netforum\xWeb\Generated\StructType\AVWizardForm
    {
        return parent::first();
    }
    /**
     * Returns the last element
     * @see AbstractStructArrayBase::last()
     * @return \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm|null
     */
    public function last(): ?\Drupal\netforum\xWeb\Generated\StructType\AVWizardForm
    {
        return parent::last();
    }
    /**
     * Returns the element at the offset
     * @see AbstractStructArrayBase::offsetGet()
     * @param int $offset
     * @return \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm|null
     */
    public function offsetGet($offset): ?\Drupal\netforum\xWeb\Generated\StructType\AVWizardForm
    {
        return parent::offsetGet($offset);
    }
    /**
     * Add element to array
     * @see AbstractStructArrayBase::add()
     * @throws InvalidArgumentException
     * @param \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm $item
     * @return \Drupal\netforum\xWeb\Generated\ArrayType\ArrayOfAVWizardForm
     */
    public function add($item): self
    {
        // validation for constraint: itemType
        if (!$item instanceof \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm) {
            throw new InvalidArgumentException(sprintf('The AVWizardForm property can only contain items of type \Drupal\netforum\xWeb\Generated\StructType\AVWizardForm, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        return parent::add($item);
    }
    /**
     * Returns the attribute name
     * @see AbstractStructArrayBase::getAttributeName()
     * @return string AVWizardForm
     */
    public function getAttributeName(): string
    {
        return 'AVWizardForm';
    }
}
