<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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