<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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