<?php

namespace CustomerManagement\ArrayType;

use \WsdlToPhp\PackageBase\AbstractStructArrayBase;

/**
 * This class stands for ArrayOfCaptureReasonFlags ArrayType
 * @subpackage Arrays
 */
class ArrayOfCaptureReasonFlags extends AbstractStructArrayBase
{
    /**
     * The CaptureReasonFlags
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var string[]
     */
    public $CaptureReasonFlags;
    /**
     * Constructor method for ArrayOfCaptureReasonFlags
     * @uses ArrayOfCaptureReasonFlags::setCaptureReasonFlags()
     * @param string[] $captureReasonFlags
     */
    public function __construct(array $captureReasonFlags = array())
    {
        $this
            ->setCaptureReasonFlags($captureReasonFlags);
    }
    /**
     * Get CaptureReasonFlags value
     * @return string[]|null
     */
    public function getCaptureReasonFlags()
    {
        return $this->CaptureReasonFlags;
    }
    /**
     * This method is responsible for validating the values passed to the setCaptureReasonFlags method
     * This method is willingly generated in order to preserve the one-line inline validation within the setCaptureReasonFlags method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateCaptureReasonFlagsForArrayConstraintsFromSetCaptureReasonFlags(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $arrayOfCaptureReasonFlagsCaptureReasonFlagsItem) {
            // validation for constraint: enumeration
            if (!\CustomerManagement\EnumType\CaptureReasonFlags::valueIsValid($arrayOfCaptureReasonFlagsCaptureReasonFlagsItem)) {
                $invalidValues[] = is_object($arrayOfCaptureReasonFlagsCaptureReasonFlagsItem) ? get_class($arrayOfCaptureReasonFlagsCaptureReasonFlagsItem) : sprintf('%s(%s)', gettype($arrayOfCaptureReasonFlagsCaptureReasonFlagsItem), var_export($arrayOfCaptureReasonFlagsCaptureReasonFlagsItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \CustomerManagement\EnumType\CaptureReasonFlags', is_array($invalidValues) ? implode(', ', $invalidValues) : var_export($invalidValues, true), implode(', ', \CustomerManagement\EnumType\CaptureReasonFlags::getValidValues()));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set CaptureReasonFlags value
     * @uses \CustomerManagement\EnumType\CaptureReasonFlags::valueIsValid()
     * @uses \CustomerManagement\EnumType\CaptureReasonFlags::getValidValues()
     * @throws \InvalidArgumentException
     * @param string[] $captureReasonFlags
     * @return \CustomerManagement\ArrayType\ArrayOfCaptureReasonFlags
     */
    public function setCaptureReasonFlags(array $captureReasonFlags = array())
    {
        // validation for constraint: array
        if ('' !== ($captureReasonFlagsArrayErrorMessage = self::validateCaptureReasonFlagsForArrayConstraintsFromSetCaptureReasonFlags($captureReasonFlags))) {
            throw new \InvalidArgumentException($captureReasonFlagsArrayErrorMessage, __LINE__);
        }
        $this->CaptureReasonFlags = is_array($captureReasonFlags) ? implode(' ', $captureReasonFlags) : null;
        return $this;
    }
    /**
     * Add item to CaptureReasonFlags value
     * @uses \CustomerManagement\EnumType\CaptureReasonFlags::valueIsValid()
     * @uses \CustomerManagement\EnumType\CaptureReasonFlags::getValidValues()
     * @throws \InvalidArgumentException
     * @param string $item
     * @return \CustomerManagement\ArrayType\ArrayOfCaptureReasonFlags
     */
    public function addToCaptureReasonFlags($item)
    {
        // validation for constraint: enumeration
        if (!\CustomerManagement\EnumType\CaptureReasonFlags::valueIsValid($item)) {
            throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \CustomerManagement\EnumType\CaptureReasonFlags', is_array($item) ? implode(', ', $item) : var_export($item, true), implode(', ', \CustomerManagement\EnumType\CaptureReasonFlags::getValidValues())), __LINE__);
        }
        $this->CaptureReasonFlags[] = $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\CaptureReasonFlags::valueIsValid()
     * @param string $item
     * @return \CustomerManagement\ArrayType\ArrayOfCaptureReasonFlags
     */
    public function add($item)
    {
        // validation for constraint: enumeration
        if (!\CustomerManagement\EnumType\CaptureReasonFlags::valueIsValid($item)) {
            throw new \InvalidArgumentException(sprintf('Invalid value(s) %s, please use one of: %s from enumeration class \CustomerManagement\EnumType\CaptureReasonFlags', is_array($item) ? implode(', ', $item) : var_export($item, true), implode(', ', \CustomerManagement\EnumType\CaptureReasonFlags::getValidValues())), __LINE__);
        }
        return parent::add($item);
    }
    /**
     * Returns the attribute name
     * @see AbstractStructArrayBase::getAttributeName()
     * @return string CaptureReasonFlags
     */
    public function getAttributeName()
    {
        return 'CaptureReasonFlags';
    }
}
