<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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