<?php

declare(strict_types=1);

namespace Drupal\netforum\xWeb\Generated\StructType;

use InvalidArgumentException;
use WsdlToPhp\PackageBase\AbstractStructBase;

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