<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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