<?php

declare(strict_types=1);

namespace Drupal\netforum\xWeb\Generated\StructType;

use InvalidArgumentException;
use WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for ExhibitorCollectionType StructType
 * @subpackage Structs
 * @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
 */
#[\AllowDynamicProperties]
class ExhibitorCollectionType extends AbstractStructBase
{
    /**
     * The ExhibitorNew
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \Drupal\netforum\xWeb\Generated\StructType\ExhibitorNewType[]
     */
    protected ?array $ExhibitorNew = null;
    /**
     * Constructor method for ExhibitorCollectionType
     * @uses ExhibitorCollectionType::setExhibitorNew()
     * @param \Drupal\netforum\xWeb\Generated\StructType\ExhibitorNewType[] $exhibitorNew
     */
    public function __construct(?array $exhibitorNew = null)
    {
        $this
            ->setExhibitorNew($exhibitorNew);
    }
    /**
     * Get ExhibitorNew value
     * @return \Drupal\netforum\xWeb\Generated\StructType\ExhibitorNewType[]
     */
    public function getExhibitorNew(): ?array
    {
        return $this->ExhibitorNew;
    }
    /**
     * This method is responsible for validating the value(s) passed to the setExhibitorNew method
     * This method is willingly generated in order to preserve the one-line inline validation within the setExhibitorNew 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 validateExhibitorNewForArrayConstraintFromSetExhibitorNew(?array $values = []): string
    {
        if (!is_array($values)) {
            return '';
        }
        $message = '';
        $invalidValues = [];
        foreach ($values as $exhibitorCollectionTypeExhibitorNewItem) {
            // validation for constraint: itemType
            if (!$exhibitorCollectionTypeExhibitorNewItem instanceof \Drupal\netforum\xWeb\Generated\StructType\ExhibitorNewType) {
                $invalidValues[] = is_object($exhibitorCollectionTypeExhibitorNewItem) ? get_class($exhibitorCollectionTypeExhibitorNewItem) : sprintf('%s(%s)', gettype($exhibitorCollectionTypeExhibitorNewItem), var_export($exhibitorCollectionTypeExhibitorNewItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The ExhibitorNew property can only contain items of type \Drupal\netforum\xWeb\Generated\StructType\ExhibitorNewType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        
        return $message;
    }
    /**
     * Set ExhibitorNew value
     * @throws InvalidArgumentException
     * @param \Drupal\netforum\xWeb\Generated\StructType\ExhibitorNewType[] $exhibitorNew
     * @return \Drupal\netforum\xWeb\Generated\StructType\ExhibitorCollectionType
     */
    public function setExhibitorNew(?array $exhibitorNew = null): self
    {
        // validation for constraint: array
        if ('' !== ($exhibitorNewArrayErrorMessage = self::validateExhibitorNewForArrayConstraintFromSetExhibitorNew($exhibitorNew))) {
            throw new InvalidArgumentException($exhibitorNewArrayErrorMessage, __LINE__);
        }
        $this->ExhibitorNew = $exhibitorNew;
        
        return $this;
    }
    /**
     * Add item to ExhibitorNew value
     * @throws InvalidArgumentException
     * @param \Drupal\netforum\xWeb\Generated\StructType\ExhibitorNewType $item
     * @return \Drupal\netforum\xWeb\Generated\StructType\ExhibitorCollectionType
     */
    public function addToExhibitorNew(\Drupal\netforum\xWeb\Generated\StructType\ExhibitorNewType $item): self
    {
        // validation for constraint: itemType
        if (!$item instanceof \Drupal\netforum\xWeb\Generated\StructType\ExhibitorNewType) {
            throw new InvalidArgumentException(sprintf('The ExhibitorNew property can only contain items of type \Drupal\netforum\xWeb\Generated\StructType\ExhibitorNewType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->ExhibitorNew[] = $item;
        
        return $this;
    }
}
