<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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