<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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