<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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