<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for Card_Holder_Listing_File_Request_ReferencesType StructType
 * Meta information extracted from the WSDL
 * - documentation: Card Holder Listing File Reference element contains the specific instance set containing the requested Card Holder Listing File.
 * @subpackage Structs
 */
class Card_Holder_Listing_File_Request_ReferencesType extends AbstractStructBase
{
    /**
     * The Card_Holder_Listing_File_Reference
     * Meta information extracted from the WSDL
     * - documentation: Instance set containing the Card Holder Listing File object.
     * - maxOccurs: unbounded
     * @var \StructType\Cardholder_Listing_FileObjectType[]
     */
    public $Card_Holder_Listing_File_Reference;
    /**
     * Constructor method for Card_Holder_Listing_File_Request_ReferencesType
     * @uses Card_Holder_Listing_File_Request_ReferencesType::setCard_Holder_Listing_File_Reference()
     * @param \StructType\Cardholder_Listing_FileObjectType[] $card_Holder_Listing_File_Reference
     */
    public function __construct(array $card_Holder_Listing_File_Reference = array())
    {
        $this
            ->setCard_Holder_Listing_File_Reference($card_Holder_Listing_File_Reference);
    }
    /**
     * Get Card_Holder_Listing_File_Reference value
     * @return \StructType\Cardholder_Listing_FileObjectType[]|null
     */
    public function getCard_Holder_Listing_File_Reference()
    {
        return $this->Card_Holder_Listing_File_Reference;
    }
    /**
     * This method is responsible for validating the values passed to the setCard_Holder_Listing_File_Reference method
     * This method is willingly generated in order to preserve the one-line inline validation within the setCard_Holder_Listing_File_Reference method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateCard_Holder_Listing_File_ReferenceForArrayConstraintsFromSetCard_Holder_Listing_File_Reference(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $card_Holder_Listing_File_Request_ReferencesTypeCard_Holder_Listing_File_ReferenceItem) {
            // validation for constraint: itemType
            if (!$card_Holder_Listing_File_Request_ReferencesTypeCard_Holder_Listing_File_ReferenceItem instanceof \StructType\Cardholder_Listing_FileObjectType) {
                $invalidValues[] = is_object($card_Holder_Listing_File_Request_ReferencesTypeCard_Holder_Listing_File_ReferenceItem) ? get_class($card_Holder_Listing_File_Request_ReferencesTypeCard_Holder_Listing_File_ReferenceItem) : sprintf('%s(%s)', gettype($card_Holder_Listing_File_Request_ReferencesTypeCard_Holder_Listing_File_ReferenceItem), var_export($card_Holder_Listing_File_Request_ReferencesTypeCard_Holder_Listing_File_ReferenceItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The Card_Holder_Listing_File_Reference property can only contain items of type \StructType\Cardholder_Listing_FileObjectType, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set Card_Holder_Listing_File_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Cardholder_Listing_FileObjectType[] $card_Holder_Listing_File_Reference
     * @return \StructType\Card_Holder_Listing_File_Request_ReferencesType
     */
    public function setCard_Holder_Listing_File_Reference(array $card_Holder_Listing_File_Reference = array())
    {
        // validation for constraint: array
        if ('' !== ($card_Holder_Listing_File_ReferenceArrayErrorMessage = self::validateCard_Holder_Listing_File_ReferenceForArrayConstraintsFromSetCard_Holder_Listing_File_Reference($card_Holder_Listing_File_Reference))) {
            throw new \InvalidArgumentException($card_Holder_Listing_File_ReferenceArrayErrorMessage, __LINE__);
        }
        $this->Card_Holder_Listing_File_Reference = $card_Holder_Listing_File_Reference;
        return $this;
    }
    /**
     * Add item to Card_Holder_Listing_File_Reference value
     * @throws \InvalidArgumentException
     * @param \StructType\Cardholder_Listing_FileObjectType $item
     * @return \StructType\Card_Holder_Listing_File_Request_ReferencesType
     */
    public function addToCard_Holder_Listing_File_Reference(\StructType\Cardholder_Listing_FileObjectType $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\Cardholder_Listing_FileObjectType) {
            throw new \InvalidArgumentException(sprintf('The Card_Holder_Listing_File_Reference property can only contain items of type \StructType\Cardholder_Listing_FileObjectType, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->Card_Holder_Listing_File_Reference[] = $item;
        return $this;
    }
}
