<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Requisition_Sourcing_RuleType StructType
 * Meta information extracted from the WSDL
 * - documentation: Contains Requisition Sourcing Rule detailed data
 * @subpackage Structs
 */
class Requisition_Sourcing_RuleType extends AbstractStructBase
{
    /**
     * The Requisition_Sourcing_Rule_Data
     * Meta information extracted from the WSDL
     * - documentation: Element that represents the contents of this Requisition Sourcing Rule.
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\Requisition_Sourcing_Rule_DataType[]
     */
    public $Requisition_Sourcing_Rule_Data;
    /**
     * Constructor method for Requisition_Sourcing_RuleType
     * @uses Requisition_Sourcing_RuleType::setRequisition_Sourcing_Rule_Data()
     * @param \StructType\Requisition_Sourcing_Rule_DataType[] $requisition_Sourcing_Rule_Data
     */
    public function __construct(array $requisition_Sourcing_Rule_Data = array())
    {
        $this
            ->setRequisition_Sourcing_Rule_Data($requisition_Sourcing_Rule_Data);
    }
    /**
     * Get Requisition_Sourcing_Rule_Data value
     * @return \StructType\Requisition_Sourcing_Rule_DataType[]|null
     */
    public function getRequisition_Sourcing_Rule_Data()
    {
        return $this->Requisition_Sourcing_Rule_Data;
    }
    /**
     * This method is responsible for validating the values passed to the setRequisition_Sourcing_Rule_Data method
     * This method is willingly generated in order to preserve the one-line inline validation within the setRequisition_Sourcing_Rule_Data method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateRequisition_Sourcing_Rule_DataForArrayConstraintsFromSetRequisition_Sourcing_Rule_Data(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $requisition_Sourcing_RuleTypeRequisition_Sourcing_Rule_DataItem) {
            // validation for constraint: itemType
            if (!$requisition_Sourcing_RuleTypeRequisition_Sourcing_Rule_DataItem instanceof \StructType\Requisition_Sourcing_Rule_DataType) {
                $invalidValues[] = is_object($requisition_Sourcing_RuleTypeRequisition_Sourcing_Rule_DataItem) ? get_class($requisition_Sourcing_RuleTypeRequisition_Sourcing_Rule_DataItem) : sprintf('%s(%s)', gettype($requisition_Sourcing_RuleTypeRequisition_Sourcing_Rule_DataItem), var_export($requisition_Sourcing_RuleTypeRequisition_Sourcing_Rule_DataItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Requisition_Sourcing_Rule_Data property can only contain items of type \StructType\Requisition_Sourcing_Rule_DataType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Requisition_Sourcing_Rule_Data value
     * @throws \InvalidArgumentException
     * @param \StructType\Requisition_Sourcing_Rule_DataType[] $requisition_Sourcing_Rule_Data
     * @return \StructType\Requisition_Sourcing_RuleType
     */
    public function setRequisition_Sourcing_Rule_Data(array $requisition_Sourcing_Rule_Data = array())
    {
        // validation for constraint: array
        if ('' !== ($requisition_Sourcing_Rule_DataArrayErrorMessage = self::validateRequisition_Sourcing_Rule_DataForArrayConstraintsFromSetRequisition_Sourcing_Rule_Data($requisition_Sourcing_Rule_Data))) {
            throw new \InvalidArgumentException($requisition_Sourcing_Rule_DataArrayErrorMessage, __LINE__);
        }
        $this->Requisition_Sourcing_Rule_Data = $requisition_Sourcing_Rule_Data;
        return $this;
    }
    /**
     * Add item to Requisition_Sourcing_Rule_Data value
     * @throws \InvalidArgumentException
     * @param \StructType\Requisition_Sourcing_Rule_DataType $item
     * @return \StructType\Requisition_Sourcing_RuleType
     */
    public function addToRequisition_Sourcing_Rule_Data(\StructType\Requisition_Sourcing_Rule_DataType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Requisition_Sourcing_Rule_DataType) {
            throw new \InvalidArgumentException(sprintf('The Requisition_Sourcing_Rule_Data property can only contain items of type \StructType\Requisition_Sourcing_Rule_DataType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Requisition_Sourcing_Rule_Data[] = $item;
        return $this;
    }
}
