<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for JP_HotelAllotmentRS StructType
 * @subpackage Structs
 */
class JP_HotelAllotmentRS extends AbstractStructBase
{
    /**
     * The Contract
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\JPSOAP_HotelAvailContract[]
     */
    public $Contract;
    /**
     * The HotelCode
     * @var string
     */
    public $HotelCode;
    /**
     * The HotelCodeEncrypt
     * @var string
     */
    public $HotelCodeEncrypt;
    /**
     * Constructor method for JP_HotelAllotmentRS
     * @uses JP_HotelAllotmentRS::setContract()
     * @uses JP_HotelAllotmentRS::setHotelCode()
     * @uses JP_HotelAllotmentRS::setHotelCodeEncrypt()
     * @param \StructType\JPSOAP_HotelAvailContract[] $contract
     * @param string $hotelCode
     * @param string $hotelCodeEncrypt
     */
    public function __construct(array $contract = array(), $hotelCode = null, $hotelCodeEncrypt = null)
    {
        $this
            ->setContract($contract)
            ->setHotelCode($hotelCode)
            ->setHotelCodeEncrypt($hotelCodeEncrypt);
    }
    /**
     * Get Contract value
     * @return \StructType\JPSOAP_HotelAvailContract[]|null
     */
    public function getContract()
    {
        return $this->Contract;
    }
    /**
     * This method is responsible for validating the values passed to the setContract method
     * This method is willingly generated in order to preserve the one-line inline validation within the setContract method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateContractForArrayConstraintsFromSetContract(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $jP_HotelAllotmentRSContractItem) {
            // validation for constraint: itemType
            if (!$jP_HotelAllotmentRSContractItem instanceof \StructType\JPSOAP_HotelAvailContract) {
                $invalidValues[] = is_object($jP_HotelAllotmentRSContractItem) ? get_class($jP_HotelAllotmentRSContractItem) : sprintf('%s(%s)', gettype($jP_HotelAllotmentRSContractItem), var_export($jP_HotelAllotmentRSContractItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Contract property can only contain items of type \StructType\JPSOAP_HotelAvailContract, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Contract value
     * @throws \InvalidArgumentException
     * @param \StructType\JPSOAP_HotelAvailContract[] $contract
     * @return \StructType\JP_HotelAllotmentRS
     */
    public function setContract(array $contract = array())
    {
        // validation for constraint: array
        if ('' !== ($contractArrayErrorMessage = self::validateContractForArrayConstraintsFromSetContract($contract))) {
            throw new \InvalidArgumentException($contractArrayErrorMessage, __LINE__);
        }
        $this->Contract = $contract;
        return $this;
    }
    /**
     * Add item to Contract value
     * @throws \InvalidArgumentException
     * @param \StructType\JPSOAP_HotelAvailContract $item
     * @return \StructType\JP_HotelAllotmentRS
     */
    public function addToContract(\StructType\JPSOAP_HotelAvailContract $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\JPSOAP_HotelAvailContract) {
            throw new \InvalidArgumentException(sprintf('The Contract property can only contain items of type \StructType\JPSOAP_HotelAvailContract, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Contract[] = $item;
        return $this;
    }
    /**
     * Get HotelCode value
     * @return string|null
     */
    public function getHotelCode()
    {
        return $this->HotelCode;
    }
    /**
     * Set HotelCode value
     * @param string $hotelCode
     * @return \StructType\JP_HotelAllotmentRS
     */
    public function setHotelCode($hotelCode = null)
    {
        // validation for constraint: string
        if (!is_null($hotelCode) && !is_string($hotelCode)) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($hotelCode, true), gettype($hotelCode)), __LINE__);
        }
        $this->HotelCode = $hotelCode;
        return $this;
    }
    /**
     * Get HotelCodeEncrypt value
     * @return string|null
     */
    public function getHotelCodeEncrypt()
    {
        return $this->HotelCodeEncrypt;
    }
    /**
     * Set HotelCodeEncrypt value
     * @param string $hotelCodeEncrypt
     * @return \StructType\JP_HotelAllotmentRS
     */
    public function setHotelCodeEncrypt($hotelCodeEncrypt = null)
    {
        // validation for constraint: string
        if (!is_null($hotelCodeEncrypt) && !is_string($hotelCodeEncrypt)) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($hotelCodeEncrypt, true), gettype($hotelCodeEncrypt)), __LINE__);
        }
        $this->HotelCodeEncrypt = $hotelCodeEncrypt;
        return $this;
    }
}
