<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Order_From_Supplier_Connection_Response_DataType
 * StructType
 * Meta information extracted from the WSDL
 * - documentation: Wrapper Element that contains Order From Supplier Connection
 * @subpackage Structs
 */
class Order_From_Supplier_Connection_Response_DataType extends AbstractStructBase
{
    /**
     * The Supplier_Connection
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\Order_From_Supplier_ConnectionType[]
     */
    public $Supplier_Connection;
    /**
     * Constructor method for Order_From_Supplier_Connection_Response_DataType
     * @uses Order_From_Supplier_Connection_Response_DataType::setSupplier_Connection()
     * @param \StructType\Order_From_Supplier_ConnectionType[] $supplier_Connection
     */
    public function __construct(array $supplier_Connection = array())
    {
        $this
            ->setSupplier_Connection($supplier_Connection);
    }
    /**
     * Get Supplier_Connection value
     * @return \StructType\Order_From_Supplier_ConnectionType[]|null
     */
    public function getSupplier_Connection()
    {
        return $this->Supplier_Connection;
    }
    /**
     * This method is responsible for validating the values passed to the setSupplier_Connection method
     * This method is willingly generated in order to preserve the one-line inline validation within the setSupplier_Connection method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateSupplier_ConnectionForArrayConstraintsFromSetSupplier_Connection(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $order_From_Supplier_Connection_Response_DataTypeSupplier_ConnectionItem) {
            // validation for constraint: itemType
            if (!$order_From_Supplier_Connection_Response_DataTypeSupplier_ConnectionItem instanceof \StructType\Order_From_Supplier_ConnectionType) {
                $invalidValues[] = is_object($order_From_Supplier_Connection_Response_DataTypeSupplier_ConnectionItem) ? get_class($order_From_Supplier_Connection_Response_DataTypeSupplier_ConnectionItem) : sprintf('%s(%s)', gettype($order_From_Supplier_Connection_Response_DataTypeSupplier_ConnectionItem), var_export($order_From_Supplier_Connection_Response_DataTypeSupplier_ConnectionItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Supplier_Connection property can only contain items of type \StructType\Order_From_Supplier_ConnectionType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Supplier_Connection value
     * @throws \InvalidArgumentException
     * @param \StructType\Order_From_Supplier_ConnectionType[] $supplier_Connection
     * @return \StructType\Order_From_Supplier_Connection_Response_DataType
     */
    public function setSupplier_Connection(array $supplier_Connection = array())
    {
        // validation for constraint: array
        if ('' !== ($supplier_ConnectionArrayErrorMessage = self::validateSupplier_ConnectionForArrayConstraintsFromSetSupplier_Connection($supplier_Connection))) {
            throw new \InvalidArgumentException($supplier_ConnectionArrayErrorMessage, __LINE__);
        }
        $this->Supplier_Connection = $supplier_Connection;
        return $this;
    }
    /**
     * Add item to Supplier_Connection value
     * @throws \InvalidArgumentException
     * @param \StructType\Order_From_Supplier_ConnectionType $item
     * @return \StructType\Order_From_Supplier_Connection_Response_DataType
     */
    public function addToSupplier_Connection(\StructType\Order_From_Supplier_ConnectionType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Order_From_Supplier_ConnectionType) {
            throw new \InvalidArgumentException(sprintf('The Supplier_Connection property can only contain items of type \StructType\Order_From_Supplier_ConnectionType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Supplier_Connection[] = $item;
        return $this;
    }
}
