<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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