<?php

namespace CustomerManagement\ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

/**
 * This class stands for ArrayOfServicePlanValidationRuleEnum ArrayType
 * @subpackage Arrays
 */
class ArrayOfServicePlanValidationRuleEnum extends AbstractStructArrayBase
{
    /**
     * The ServicePlanValidationRuleEnum
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var string[]
     */
    public $ServicePlanValidationRuleEnum;
    /**
     * Constructor method for ArrayOfServicePlanValidationRuleEnum
     * @uses ArrayOfServicePlanValidationRuleEnum::setServicePlanValidationRuleEnum()
     * @param string[] $servicePlanValidationRuleEnum
     */
    public function __construct(array $servicePlanValidationRuleEnum = array())
    {
        $this
            ->setServicePlanValidationRuleEnum($servicePlanValidationRuleEnum);
    }
    /**
     * Get ServicePlanValidationRuleEnum value
     * @return string[]|null
     */
    public function getServicePlanValidationRuleEnum()
    {
        return $this->ServicePlanValidationRuleEnum;
    }
    /**
     * This method is responsible for validating the values passed to the setServicePlanValidationRuleEnum method
     * This method is willingly generated in order to preserve the one-line inline validation within the setServicePlanValidationRuleEnum method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateServicePlanValidationRuleEnumForArrayConstraintsFromSetServicePlanValidationRuleEnum(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $arrayOfServicePlanValidationRuleEnumServicePlanValidationRuleEnumItem) {
            // validation for constraint: enumeration
            if (!\CustomerManagement\EnumType\ServicePlanValidationRuleEnum::valueIsValid($arrayOfServicePlanValidationRuleEnumServicePlanValidationRuleEnumItem)) {
                $invalidValues[] = is_object($arrayOfServicePlanValidationRuleEnumServicePlanValidationRuleEnumItem) ? get_class($arrayOfServicePlanValidationRuleEnumServicePlanValidationRuleEnumItem) : sprintf('%s(%s)', gettype($arrayOfServicePlanValidationRuleEnumServicePlanValidationRuleEnumItem), var_export($arrayOfServicePlanValidationRuleEnumServicePlanValidationRuleEnumItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \CustomerManagement\EnumType\ServicePlanValidationRuleEnum', is_array($invalidValues) ? implode(', ', $invalidValues) : var_export($invalidValues, true), implode(', ', \CustomerManagement\EnumType\ServicePlanValidationRuleEnum::getValidValues()));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set ServicePlanValidationRuleEnum value
     * @uses \CustomerManagement\EnumType\ServicePlanValidationRuleEnum::valueIsValid()
     * @uses \CustomerManagement\EnumType\ServicePlanValidationRuleEnum::getValidValues()
     * @throws \InvalidArgumentException
     * @param string[] $servicePlanValidationRuleEnum
     * @return \CustomerManagement\ArrayType\ArrayOfServicePlanValidationRuleEnum
     */
    public function setServicePlanValidationRuleEnum(array $servicePlanValidationRuleEnum = array())
    {
        // validation for constraint: array
        if ('' !== ($servicePlanValidationRuleEnumArrayErrorMessage = self::validateServicePlanValidationRuleEnumForArrayConstraintsFromSetServicePlanValidationRuleEnum($servicePlanValidationRuleEnum))) {
            throw new \InvalidArgumentException($servicePlanValidationRuleEnumArrayErrorMessage, __LINE__);
        }
        $this->ServicePlanValidationRuleEnum = $servicePlanValidationRuleEnum;
        return $this;
    }
    /**
     * Add item to ServicePlanValidationRuleEnum value
     * @uses \CustomerManagement\EnumType\ServicePlanValidationRuleEnum::valueIsValid()
     * @uses \CustomerManagement\EnumType\ServicePlanValidationRuleEnum::getValidValues()
     * @throws \InvalidArgumentException
     * @param string $item
     * @return \CustomerManagement\ArrayType\ArrayOfServicePlanValidationRuleEnum
     */
    public function addToServicePlanValidationRuleEnum($item)
    {
        // validation for constraint: enumeration
        if (!\CustomerManagement\EnumType\ServicePlanValidationRuleEnum::valueIsValid($item)) {
            throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \CustomerManagement\EnumType\ServicePlanValidationRuleEnum', is_array($item) ? implode(', ', $item) : var_export($item, true), implode(', ', \CustomerManagement\EnumType\ServicePlanValidationRuleEnum::getValidValues())), __LINE__);
        }
        $this->ServicePlanValidationRuleEnum[] = $item;
        return $this;
    }
    /**
     * Returns the current element
     * @see AbstractStructArrayBase::current()
     * @return string|null
     */
    public function current()
    {
        return parent::current();
    }
    /**
     * Returns the indexed element
     * @see AbstractStructArrayBase::item()
     * @param int $index
     * @return string|null
     */
    public function item($index)
    {
        return parent::item($index);
    }
    /**
     * Returns the first element
     * @see AbstractStructArrayBase::first()
     * @return string|null
     */
    public function first()
    {
        return parent::first();
    }
    /**
     * Returns the last element
     * @see AbstractStructArrayBase::last()
     * @return string|null
     */
    public function last()
    {
        return parent::last();
    }
    /**
     * Returns the element at the offset
     * @see AbstractStructArrayBase::offsetGet()
     * @param int $offset
     * @return string|null
     */
    public function offsetGet($offset)
    {
        return parent::offsetGet($offset);
    }
    /**
     * Add element to array
     * @see AbstractStructArrayBase::add()
     * @throws \InvalidArgumentException
     * @uses \CustomerManagement\EnumType\ServicePlanValidationRuleEnum::valueIsValid()
     * @param string $item
     * @return \CustomerManagement\ArrayType\ArrayOfServicePlanValidationRuleEnum
     */
    public function add($item)
    {
        // validation for constraint: enumeration
        if (!\CustomerManagement\EnumType\ServicePlanValidationRuleEnum::valueIsValid($item)) {
            throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \CustomerManagement\EnumType\ServicePlanValidationRuleEnum', is_array($item) ? implode(', ', $item) : var_export($item, true), implode(', ', \CustomerManagement\EnumType\ServicePlanValidationRuleEnum::getValidValues())), __LINE__);
        }
        return parent::add($item);
    }
    /**
     * Returns the attribute name
     * @see AbstractStructArrayBase::getAttributeName()
     * @return string ServicePlanValidationRuleEnum
     */
    public function getAttributeName()
    {
        return 'ServicePlanValidationRuleEnum';
    }
}
