<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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