<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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