<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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