<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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