<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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