<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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