<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Supplier_Invoice_Assignment_Rule_Response_DataType
 * StructType
 * Meta information extracted from the WSDL
 * - documentation: Response data element for Supplier Invoice Assignment Rule.
 * @subpackage Structs
 */
class Supplier_Invoice_Assignment_Rule_Response_DataType extends AbstractStructBase
{
    /**
     * The Supplier_Invoice_Assignment_Rule
     * Meta information extracted from the WSDL
     * - documentation: Element containing response data for Supplier Invoice Assignment Rule.
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\Supplier_Invoice_Assignment_RuleType[]
     */
    public $Supplier_Invoice_Assignment_Rule;
    /**
     * Constructor method for Supplier_Invoice_Assignment_Rule_Response_DataType
     * @uses Supplier_Invoice_Assignment_Rule_Response_DataType::setSupplier_Invoice_Assignment_Rule()
     * @param \StructType\Supplier_Invoice_Assignment_RuleType[] $supplier_Invoice_Assignment_Rule
     */
    public function __construct(array $supplier_Invoice_Assignment_Rule = array())
    {
        $this
            ->setSupplier_Invoice_Assignment_Rule($supplier_Invoice_Assignment_Rule);
    }
    /**
     * Get Supplier_Invoice_Assignment_Rule value
     * @return \StructType\Supplier_Invoice_Assignment_RuleType[]|null
     */
    public function getSupplier_Invoice_Assignment_Rule()
    {
        return $this->Supplier_Invoice_Assignment_Rule;
    }
    /**
     * This method is responsible for validating the values passed to the setSupplier_Invoice_Assignment_Rule method
     * This method is willingly generated in order to preserve the one-line inline validation within the setSupplier_Invoice_Assignment_Rule method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateSupplier_Invoice_Assignment_RuleForArrayConstraintsFromSetSupplier_Invoice_Assignment_Rule(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $supplier_Invoice_Assignment_Rule_Response_DataTypeSupplier_Invoice_Assignment_RuleItem) {
            // validation for constraint: itemType
            if (!$supplier_Invoice_Assignment_Rule_Response_DataTypeSupplier_Invoice_Assignment_RuleItem instanceof \StructType\Supplier_Invoice_Assignment_RuleType) {
                $invalidValues[] = is_object($supplier_Invoice_Assignment_Rule_Response_DataTypeSupplier_Invoice_Assignment_RuleItem) ? get_class($supplier_Invoice_Assignment_Rule_Response_DataTypeSupplier_Invoice_Assignment_RuleItem) : sprintf('%s(%s)', gettype($supplier_Invoice_Assignment_Rule_Response_DataTypeSupplier_Invoice_Assignment_RuleItem), var_export($supplier_Invoice_Assignment_Rule_Response_DataTypeSupplier_Invoice_Assignment_RuleItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Supplier_Invoice_Assignment_Rule property can only contain items of type \StructType\Supplier_Invoice_Assignment_RuleType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Supplier_Invoice_Assignment_Rule value
     * @throws \InvalidArgumentException
     * @param \StructType\Supplier_Invoice_Assignment_RuleType[] $supplier_Invoice_Assignment_Rule
     * @return \StructType\Supplier_Invoice_Assignment_Rule_Response_DataType
     */
    public function setSupplier_Invoice_Assignment_Rule(array $supplier_Invoice_Assignment_Rule = array())
    {
        // validation for constraint: array
        if ('' !== ($supplier_Invoice_Assignment_RuleArrayErrorMessage = self::validateSupplier_Invoice_Assignment_RuleForArrayConstraintsFromSetSupplier_Invoice_Assignment_Rule($supplier_Invoice_Assignment_Rule))) {
            throw new \InvalidArgumentException($supplier_Invoice_Assignment_RuleArrayErrorMessage, __LINE__);
        }
        $this->Supplier_Invoice_Assignment_Rule = $supplier_Invoice_Assignment_Rule;
        return $this;
    }
    /**
     * Add item to Supplier_Invoice_Assignment_Rule value
     * @throws \InvalidArgumentException
     * @param \StructType\Supplier_Invoice_Assignment_RuleType $item
     * @return \StructType\Supplier_Invoice_Assignment_Rule_Response_DataType
     */
    public function addToSupplier_Invoice_Assignment_Rule(\StructType\Supplier_Invoice_Assignment_RuleType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Supplier_Invoice_Assignment_RuleType) {
            throw new \InvalidArgumentException(sprintf('The Supplier_Invoice_Assignment_Rule property can only contain items of type \StructType\Supplier_Invoice_Assignment_RuleType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Supplier_Invoice_Assignment_Rule[] = $item;
        return $this;
    }
}
