<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for JP_RoomList StructType
 * @subpackage Structs
 */
class JP_RoomList extends AbstractStructBase
{
    /**
     * The Room
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\JP_RoomInfo[]
     */
    public $Room;
    /**
     * The RecordsPerPage
     * @var int
     */
    public $RecordsPerPage;
    /**
     * The TotalRecords
     * @var int
     */
    public $TotalRecords;
    /**
     * The NextToken
     * @var string
     */
    public $NextToken;
    /**
     * Constructor method for JP_RoomList
     * @uses JP_RoomList::setRoom()
     * @uses JP_RoomList::setRecordsPerPage()
     * @uses JP_RoomList::setTotalRecords()
     * @uses JP_RoomList::setNextToken()
     * @param \StructType\JP_RoomInfo[] $room
     * @param int $recordsPerPage
     * @param int $totalRecords
     * @param string $nextToken
     */
    public function __construct(array $room = array(), $recordsPerPage = null, $totalRecords = null, $nextToken = null)
    {
        $this
            ->setRoom($room)
            ->setRecordsPerPage($recordsPerPage)
            ->setTotalRecords($totalRecords)
            ->setNextToken($nextToken);
    }
    /**
     * Get Room value
     * @return \StructType\JP_RoomInfo[]|null
     */
    public function getRoom()
    {
        return $this->Room;
    }
    /**
     * This method is responsible for validating the values passed to the setRoom method
     * This method is willingly generated in order to preserve the one-line inline validation within the setRoom method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateRoomForArrayConstraintsFromSetRoom(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $jP_RoomListRoomItem) {
            // validation for constraint: itemType
            if (!$jP_RoomListRoomItem instanceof \StructType\JP_RoomInfo) {
                $invalidValues[] = is_object($jP_RoomListRoomItem) ? get_class($jP_RoomListRoomItem) : sprintf('%s(%s)', gettype($jP_RoomListRoomItem), var_export($jP_RoomListRoomItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Room property can only contain items of type \StructType\JP_RoomInfo, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Room value
     * @throws \InvalidArgumentException
     * @param \StructType\JP_RoomInfo[] $room
     * @return \StructType\JP_RoomList
     */
    public function setRoom(array $room = array())
    {
        // validation for constraint: array
        if ('' !== ($roomArrayErrorMessage = self::validateRoomForArrayConstraintsFromSetRoom($room))) {
            throw new \InvalidArgumentException($roomArrayErrorMessage, __LINE__);
        }
        $this->Room = $room;
        return $this;
    }
    /**
     * Add item to Room value
     * @throws \InvalidArgumentException
     * @param \StructType\JP_RoomInfo $item
     * @return \StructType\JP_RoomList
     */
    public function addToRoom(\StructType\JP_RoomInfo $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\JP_RoomInfo) {
            throw new \InvalidArgumentException(sprintf('The Room property can only contain items of type \StructType\JP_RoomInfo, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Room[] = $item;
        return $this;
    }
    /**
     * Get RecordsPerPage value
     * @return int|null
     */
    public function getRecordsPerPage()
    {
        return $this->RecordsPerPage;
    }
    /**
     * Set RecordsPerPage value
     * @param int $recordsPerPage
     * @return \StructType\JP_RoomList
     */
    public function setRecordsPerPage($recordsPerPage = null)
    {
        // validation for constraint: int
        if (!is_null($recordsPerPage) && !(is_int($recordsPerPage) || ctype_digit($recordsPerPage))) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide an integer value, %s given', var_export($recordsPerPage, true), gettype($recordsPerPage)), __LINE__);
        }
        $this->RecordsPerPage = $recordsPerPage;
        return $this;
    }
    /**
     * Get TotalRecords value
     * @return int|null
     */
    public function getTotalRecords()
    {
        return $this->TotalRecords;
    }
    /**
     * Set TotalRecords value
     * @param int $totalRecords
     * @return \StructType\JP_RoomList
     */
    public function setTotalRecords($totalRecords = null)
    {
        // validation for constraint: int
        if (!is_null($totalRecords) && !(is_int($totalRecords) || ctype_digit($totalRecords))) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide an integer value, %s given', var_export($totalRecords, true), gettype($totalRecords)), __LINE__);
        }
        $this->TotalRecords = $totalRecords;
        return $this;
    }
    /**
     * Get NextToken value
     * @return string|null
     */
    public function getNextToken()
    {
        return $this->NextToken;
    }
    /**
     * Set NextToken value
     * @param string $nextToken
     * @return \StructType\JP_RoomList
     */
    public function setNextToken($nextToken = null)
    {
        // validation for constraint: string
        if (!is_null($nextToken) && !is_string($nextToken)) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($nextToken, true), gettype($nextToken)), __LINE__);
        }
        $this->NextToken = $nextToken;
        return $this;
    }
}
