<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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