<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Business_Entity_Contact_Request_ReferencesType StructType
 * Meta information extracted from the WSDL
 * - documentation: Element containing reference instances for a Business Entity Contact
 * @subpackage Structs
 */
class Business_Entity_Contact_Request_ReferencesType extends AbstractStructBase
{
    /**
     * The Business_Entity_Contact_Reference
     * Meta information extracted from the WSDL
     * - documentation: Business Entity Contact Reference
     * - maxOccurs: unbounded
     * @var \StructType\Business_Entity_ContactObjectType[]
     */
    public $Business_Entity_Contact_Reference;
    /**
     * Constructor method for Business_Entity_Contact_Request_ReferencesType
     * @uses Business_Entity_Contact_Request_ReferencesType::setBusiness_Entity_Contact_Reference()
     * @param \StructType\Business_Entity_ContactObjectType[] $business_Entity_Contact_Reference
     */
    public function __construct(array $business_Entity_Contact_Reference = array())
    {
        $this
            ->setBusiness_Entity_Contact_Reference($business_Entity_Contact_Reference);
    }
    /**
     * Get Business_Entity_Contact_Reference value
     * @return \StructType\Business_Entity_ContactObjectType[]|null
     */
    public function getBusiness_Entity_Contact_Reference()
    {
        return $this->Business_Entity_Contact_Reference;
    }
    /**
     * This method is responsible for validating the values passed to the setBusiness_Entity_Contact_Reference method
     * This method is willingly generated in order to preserve the one-line inline validation within the setBusiness_Entity_Contact_Reference method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateBusiness_Entity_Contact_ReferenceForArrayConstraintsFromSetBusiness_Entity_Contact_Reference(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $business_Entity_Contact_Request_ReferencesTypeBusiness_Entity_Contact_ReferenceItem) {
            // validation for constraint: itemType
            if (!$business_Entity_Contact_Request_ReferencesTypeBusiness_Entity_Contact_ReferenceItem instanceof \StructType\Business_Entity_ContactObjectType) {
                $invalidValues[] = is_object($business_Entity_Contact_Request_ReferencesTypeBusiness_Entity_Contact_ReferenceItem) ? get_class($business_Entity_Contact_Request_ReferencesTypeBusiness_Entity_Contact_ReferenceItem) : sprintf('%s(%s)', gettype($business_Entity_Contact_Request_ReferencesTypeBusiness_Entity_Contact_ReferenceItem), var_export($business_Entity_Contact_Request_ReferencesTypeBusiness_Entity_Contact_ReferenceItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Business_Entity_Contact_Reference property can only contain items of type \StructType\Business_Entity_ContactObjectType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Business_Entity_Contact_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Business_Entity_ContactObjectType[] $business_Entity_Contact_Reference
     * @return \StructType\Business_Entity_Contact_Request_ReferencesType
     */
    public function setBusiness_Entity_Contact_Reference(array $business_Entity_Contact_Reference = array())
    {
        // validation for constraint: array
        if ('' !== ($business_Entity_Contact_ReferenceArrayErrorMessage = self::validateBusiness_Entity_Contact_ReferenceForArrayConstraintsFromSetBusiness_Entity_Contact_Reference($business_Entity_Contact_Reference))) {
            throw new \InvalidArgumentException($business_Entity_Contact_ReferenceArrayErrorMessage, __LINE__);
        }
        $this->Business_Entity_Contact_Reference = $business_Entity_Contact_Reference;
        return $this;
    }
    /**
     * Add item to Business_Entity_Contact_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Business_Entity_ContactObjectType $item
     * @return \StructType\Business_Entity_Contact_Request_ReferencesType
     */
    public function addToBusiness_Entity_Contact_Reference(\StructType\Business_Entity_ContactObjectType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Business_Entity_ContactObjectType) {
            throw new \InvalidArgumentException(sprintf('The Business_Entity_Contact_Reference property can only contain items of type \StructType\Business_Entity_ContactObjectType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Business_Entity_Contact_Reference[] = $item;
        return $this;
    }
}
