<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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