<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for SupportCaseEscalateToList StructType
 * @subpackage Structs
 */
class SupportCaseEscalateToList extends AbstractStructBase
{
    /**
     * The escalateTo
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\SupportCaseEscalateTo[]
     */
    public $escalateTo;
    /**
     * The replaceAll
     * Meta information extracted from the WSDL
     * - default: true
     * @var bool
     */
    public $replaceAll;
    /**
     * Constructor method for SupportCaseEscalateToList
     * @uses SupportCaseEscalateToList::setEscalateTo()
     * @uses SupportCaseEscalateToList::setReplaceAll()
     * @param \StructType\SupportCaseEscalateTo[] $escalateTo
     * @param bool $replaceAll
     */
    public function __construct(array $escalateTo = array(), $replaceAll = true)
    {
        $this
            ->setEscalateTo($escalateTo)
            ->setReplaceAll($replaceAll);
    }
    /**
     * Get escalateTo value
     * @return \StructType\SupportCaseEscalateTo[]|null
     */
    public function getEscalateTo()
    {
        return $this->escalateTo;
    }
    /**
     * This method is responsible for validating the values passed to the setEscalateTo method
     * This method is willingly generated in order to preserve the one-line inline validation within the setEscalateTo method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateEscalateToForArrayConstraintsFromSetEscalateTo(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $supportCaseEscalateToListEscalateToItem) {
            // validation for constraint: itemType
            if (!$supportCaseEscalateToListEscalateToItem instanceof \StructType\SupportCaseEscalateTo) {
                $invalidValues[] = is_object($supportCaseEscalateToListEscalateToItem) ? get_class($supportCaseEscalateToListEscalateToItem) : sprintf('%s(%s)', gettype($supportCaseEscalateToListEscalateToItem), var_export($supportCaseEscalateToListEscalateToItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The escalateTo property can only contain items of type \StructType\SupportCaseEscalateTo, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set escalateTo value
     * @throws \InvalidArgumentException
     * @param \StructType\SupportCaseEscalateTo[] $escalateTo
     * @return \StructType\SupportCaseEscalateToList
     */
    public function setEscalateTo(array $escalateTo = array())
    {
        // validation for constraint: array
        if ('' !== ($escalateToArrayErrorMessage = self::validateEscalateToForArrayConstraintsFromSetEscalateTo($escalateTo))) {
            throw new \InvalidArgumentException($escalateToArrayErrorMessage, __LINE__);
        }
        $this->escalateTo = $escalateTo;
        return $this;
    }
    /**
     * Add item to escalateTo value
     * @throws \InvalidArgumentException
     * @param \StructType\SupportCaseEscalateTo $item
     * @return \StructType\SupportCaseEscalateToList
     */
    public function addToEscalateTo(\StructType\SupportCaseEscalateTo $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\SupportCaseEscalateTo) {
            throw new \InvalidArgumentException(sprintf('The escalateTo property can only contain items of type \StructType\SupportCaseEscalateTo, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->escalateTo[] = $item;
        return $this;
    }
    /**
     * Get replaceAll value
     * @return bool|null
     */
    public function getReplaceAll()
    {
        return $this->replaceAll;
    }
    /**
     * Set replaceAll value
     * @param bool $replaceAll
     * @return \StructType\SupportCaseEscalateToList
     */
    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;
    }
}
