<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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