<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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