<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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