<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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