<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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