<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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