<?php

declare(strict_types=1);

namespace Drupal\netforum\xWeb\Generated\StructType;

use InvalidArgumentException;
use WsdlToPhp\PackageBase\AbstractStructBase;

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