<?php

declare(strict_types=1);

namespace Drupal\netforum\xWeb\Generated\StructType;

use InvalidArgumentException;
use WsdlToPhp\PackageBase\AbstractStructBase;

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