<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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