<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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