<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for GiftCertRedemptionList StructType
 * @subpackage Structs
 */
class GiftCertRedemptionList extends AbstractStructBase
{
    /**
     * The giftCertRedemption
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\GiftCertRedemption[]
     */
    public $giftCertRedemption;
    /**
     * The replaceAll
     * Meta information extracted from the WSDL
     * - default: true
     * @var bool
     */
    public $replaceAll;
    /**
     * Constructor method for GiftCertRedemptionList
     * @uses GiftCertRedemptionList::setGiftCertRedemption()
     * @uses GiftCertRedemptionList::setReplaceAll()
     * @param \StructType\GiftCertRedemption[] $giftCertRedemption
     * @param bool $replaceAll
     */
    public function __construct(array $giftCertRedemption = array(), $replaceAll = true)
    {
        $this
            ->setGiftCertRedemption($giftCertRedemption)
            ->setReplaceAll($replaceAll);
    }
    /**
     * Get giftCertRedemption value
     * @return \StructType\GiftCertRedemption[]|null
     */
    public function getGiftCertRedemption()
    {
        return $this->giftCertRedemption;
    }
    /**
     * This method is responsible for validating the values passed to the setGiftCertRedemption method
     * This method is willingly generated in order to preserve the one-line inline validation within the setGiftCertRedemption method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateGiftCertRedemptionForArrayConstraintsFromSetGiftCertRedemption(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $giftCertRedemptionListGiftCertRedemptionItem) {
            // validation for constraint: itemType
            if (!$giftCertRedemptionListGiftCertRedemptionItem instanceof \StructType\GiftCertRedemption) {
                $invalidValues[] = is_object($giftCertRedemptionListGiftCertRedemptionItem) ? get_class($giftCertRedemptionListGiftCertRedemptionItem) : sprintf('%s(%s)', gettype($giftCertRedemptionListGiftCertRedemptionItem), var_export($giftCertRedemptionListGiftCertRedemptionItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The giftCertRedemption property can only contain items of type \StructType\GiftCertRedemption, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set giftCertRedemption value
     * @throws \InvalidArgumentException
     * @param \StructType\GiftCertRedemption[] $giftCertRedemption
     * @return \StructType\GiftCertRedemptionList
     */
    public function setGiftCertRedemption(array $giftCertRedemption = array())
    {
        // validation for constraint: array
        if ('' !== ($giftCertRedemptionArrayErrorMessage = self::validateGiftCertRedemptionForArrayConstraintsFromSetGiftCertRedemption($giftCertRedemption))) {
            throw new \InvalidArgumentException($giftCertRedemptionArrayErrorMessage, __LINE__);
        }
        $this->giftCertRedemption = $giftCertRedemption;
        return $this;
    }
    /**
     * Add item to giftCertRedemption value
     * @throws \InvalidArgumentException
     * @param \StructType\GiftCertRedemption $item
     * @return \StructType\GiftCertRedemptionList
     */
    public function addToGiftCertRedemption(\StructType\GiftCertRedemption $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\GiftCertRedemption) {
            throw new \InvalidArgumentException(sprintf('The giftCertRedemption property can only contain items of type \StructType\GiftCertRedemption, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->giftCertRedemption[] = $item;
        return $this;
    }
    /**
     * Get replaceAll value
     * @return bool|null
     */
    public function getReplaceAll()
    {
        return $this->replaceAll;
    }
    /**
     * Set replaceAll value
     * @param bool $replaceAll
     * @return \StructType\GiftCertRedemptionList
     */
    public function setReplaceAll($replaceAll = true)
    {
        // validation for constraint: boolean
        if (!is_null($replaceAll) && !is_bool($replaceAll)) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($replaceAll, true), gettype($replaceAll)), __LINE__);
        }
        $this->replaceAll = $replaceAll;
        return $this;
    }
}
