<?php

namespace patest\StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for
 * RecordSetOfBizAction.Ticketing.ImportHallVersion.PriceLevelMapping StructType
 * @subpackage Structs
 */
class RecordSetOfBizAction_Ticketing_ImportHallVersion_PriceLevelMapping extends AbstractStructBase
{
    /**
     * The Record
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * - nillable: true
     * @var \patest\StructType\BizAction_Ticketing_ImportHallVersion_PriceLevelMapping[]
     */
    public $Record;
    /**
     * Constructor method for
     * RecordSetOfBizAction.Ticketing.ImportHallVersion.PriceLevelMapping
     * @uses RecordSetOfBizAction_Ticketing_ImportHallVersion_PriceLevelMapping::setRecord()
     * @param \patest\StructType\BizAction_Ticketing_ImportHallVersion_PriceLevelMapping[] $record
     */
    public function __construct(array $record = array())
    {
        $this
            ->setRecord($record);
    }
    /**
     * Get Record value
     * An additional test has been added (isset) before returning the property value as
     * this property may have been unset before, due to the fact that this property is
     * removable from the request (nillable=true+minOccurs=0)
     * @return \patest\StructType\BizAction_Ticketing_ImportHallVersion_PriceLevelMapping[]|null
     */
    public function getRecord()
    {
        return isset($this->Record) ? $this->Record : null;
    }
    /**
     * This method is responsible for validating the values passed to the setRecord method
     * This method is willingly generated in order to preserve the one-line inline validation within the setRecord method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateRecordForArrayConstraintsFromSetRecord(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $recordSetOfBizAction_Ticketing_ImportHallVersion_PriceLevelMappingRecordItem) {
            // validation for constraint: itemType
            if (!$recordSetOfBizAction_Ticketing_ImportHallVersion_PriceLevelMappingRecordItem instanceof \patest\StructType\BizAction_Ticketing_ImportHallVersion_PriceLevelMapping) {
                $invalidValues[] = is_object($recordSetOfBizAction_Ticketing_ImportHallVersion_PriceLevelMappingRecordItem) ? get_class($recordSetOfBizAction_Ticketing_ImportHallVersion_PriceLevelMappingRecordItem) : sprintf('%s(%s)', gettype($recordSetOfBizAction_Ticketing_ImportHallVersion_PriceLevelMappingRecordItem), var_export($recordSetOfBizAction_Ticketing_ImportHallVersion_PriceLevelMappingRecordItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Record property can only contain items of type \patest\StructType\BizAction_Ticketing_ImportHallVersion_PriceLevelMapping, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Record value
     * This property is removable from request (nillable=true+minOccurs=0), therefore
     * if the value assigned to this property is null, it is removed from this object
     * @throws \InvalidArgumentException
     * @param \patest\StructType\BizAction_Ticketing_ImportHallVersion_PriceLevelMapping[] $record
     * @return \patest\StructType\RecordSetOfBizAction_Ticketing_ImportHallVersion_PriceLevelMapping
     */
    public function setRecord(array $record = array())
    {
        // validation for constraint: array
        if ('' !== ($recordArrayErrorMessage = self::validateRecordForArrayConstraintsFromSetRecord($record))) {
            throw new \InvalidArgumentException($recordArrayErrorMessage, __LINE__);
        }
        if (is_null($record) || (is_array($record) && empty($record))) {
            unset($this->Record);
        } else {
            $this->Record = $record;
        }
        return $this;
    }
    /**
     * Add item to Record value
     * @throws \InvalidArgumentException
     * @param \patest\StructType\BizAction_Ticketing_ImportHallVersion_PriceLevelMapping $item
     * @return \patest\StructType\RecordSetOfBizAction_Ticketing_ImportHallVersion_PriceLevelMapping
     */
    public function addToRecord(\patest\StructType\BizAction_Ticketing_ImportHallVersion_PriceLevelMapping $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \patest\StructType\BizAction_Ticketing_ImportHallVersion_PriceLevelMapping) {
            throw new \InvalidArgumentException(sprintf('The Record property can only contain items of type \patest\StructType\BizAction_Ticketing_ImportHallVersion_PriceLevelMapping, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Record[] = $item;
        return $this;
    }
}
