<?php

declare(strict_types=1);

namespace Drupal\netforum\xWeb\Generated\ArrayType;

use InvalidArgumentException;
use WsdlToPhp\PackageBase\AbstractStructArrayBase;

/**
 * This class stands for ArrayOfCeuCreditResult 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 ArrayOfCeuCreditResult extends AbstractStructArrayBase
{
    /**
     * The CeuCreditResult
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult[]
     */
    protected ?array $CeuCreditResult = null;
    /**
     * Constructor method for ArrayOfCeuCreditResult
     * @uses ArrayOfCeuCreditResult::setCeuCreditResult()
     * @param \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult[] $ceuCreditResult
     */
    public function __construct(?array $ceuCreditResult = null)
    {
        $this
            ->setCeuCreditResult($ceuCreditResult);
    }
    /**
     * Get CeuCreditResult value
     * @return \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult[]
     */
    public function getCeuCreditResult(): ?array
    {
        return $this->CeuCreditResult;
    }
    /**
     * This method is responsible for validating the value(s) passed to the setCeuCreditResult method
     * This method is willingly generated in order to preserve the one-line inline validation within the setCeuCreditResult 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 validateCeuCreditResultForArrayConstraintFromSetCeuCreditResult(?array $values = []): string
    {
        if (!is_array($values)) {
            return '';
        }
        $message = '';
        $invalidValues = [];
        foreach ($values as $arrayOfCeuCreditResultCeuCreditResultItem) {
            // validation for constraint: itemType
            if (!$arrayOfCeuCreditResultCeuCreditResultItem instanceof \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult) {
                $invalidValues[] = is_object($arrayOfCeuCreditResultCeuCreditResultItem) ? get_class($arrayOfCeuCreditResultCeuCreditResultItem) : sprintf('%s(%s)', gettype($arrayOfCeuCreditResultCeuCreditResultItem), var_export($arrayOfCeuCreditResultCeuCreditResultItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The CeuCreditResult property can only contain items of type \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        
        return $message;
    }
    /**
     * Set CeuCreditResult value
     * @throws InvalidArgumentException
     * @param \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult[] $ceuCreditResult
     * @return \Drupal\netforum\xWeb\Generated\ArrayType\ArrayOfCeuCreditResult
     */
    public function setCeuCreditResult(?array $ceuCreditResult = null): self
    {
        // validation for constraint: array
        if ('' !== ($ceuCreditResultArrayErrorMessage = self::validateCeuCreditResultForArrayConstraintFromSetCeuCreditResult($ceuCreditResult))) {
            throw new InvalidArgumentException($ceuCreditResultArrayErrorMessage, __LINE__);
        }
        $this->CeuCreditResult = $ceuCreditResult;
        
        return $this;
    }
    /**
     * Returns the current element
     * @see AbstractStructArrayBase::current()
     * @return \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult|null
     */
    public function current(): ?\Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult
    {
        return parent::current();
    }
    /**
     * Returns the indexed element
     * @see AbstractStructArrayBase::item()
     * @param int $index
     * @return \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult|null
     */
    public function item($index): ?\Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult
    {
        return parent::item($index);
    }
    /**
     * Returns the first element
     * @see AbstractStructArrayBase::first()
     * @return \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult|null
     */
    public function first(): ?\Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult
    {
        return parent::first();
    }
    /**
     * Returns the last element
     * @see AbstractStructArrayBase::last()
     * @return \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult|null
     */
    public function last(): ?\Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult
    {
        return parent::last();
    }
    /**
     * Returns the element at the offset
     * @see AbstractStructArrayBase::offsetGet()
     * @param int $offset
     * @return \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult|null
     */
    public function offsetGet($offset): ?\Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult
    {
        return parent::offsetGet($offset);
    }
    /**
     * Add element to array
     * @see AbstractStructArrayBase::add()
     * @throws InvalidArgumentException
     * @param \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult $item
     * @return \Drupal\netforum\xWeb\Generated\ArrayType\ArrayOfCeuCreditResult
     */
    public function add($item): self
    {
        // validation for constraint: itemType
        if (!$item instanceof \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult) {
            throw new InvalidArgumentException(sprintf('The CeuCreditResult property can only contain items of type \Drupal\netforum\xWeb\Generated\StructType\CeuCreditResult, %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 CeuCreditResult
     */
    public function getAttributeName(): string
    {
        return 'CeuCreditResult';
    }
}
