<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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