<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for DepositOtherList StructType
 * @subpackage Structs
 */
class DepositOtherList extends AbstractStructBase
{
    /**
     * The depositOther
     * Meta information extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var \StructType\DepositOther[]
     */
    public $depositOther;
    /**
     * The replaceAll
     * Meta information extracted from the WSDL
     * - default: true
     * @var bool
     */
    public $replaceAll;
    /**
     * Constructor method for DepositOtherList
     * @uses DepositOtherList::setDepositOther()
     * @uses DepositOtherList::setReplaceAll()
     * @param \StructType\DepositOther[] $depositOther
     * @param bool $replaceAll
     */
    public function __construct(array $depositOther = array(), $replaceAll = true)
    {
        $this
            ->setDepositOther($depositOther)
            ->setReplaceAll($replaceAll);
    }
    /**
     * Get depositOther value
     * @return \StructType\DepositOther[]|null
     */
    public function getDepositOther()
    {
        return $this->depositOther;
    }
    /**
     * This method is responsible for validating the values passed to the setDepositOther method
     * This method is willingly generated in order to preserve the one-line inline validation within the setDepositOther method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateDepositOtherForArrayConstraintsFromSetDepositOther(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $depositOtherListDepositOtherItem) {
            // validation for constraint: itemType
            if (!$depositOtherListDepositOtherItem instanceof \StructType\DepositOther) {
                $invalidValues[] = is_object($depositOtherListDepositOtherItem) ? get_class($depositOtherListDepositOtherItem) : sprintf('%s(%s)', gettype($depositOtherListDepositOtherItem), var_export($depositOtherListDepositOtherItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The depositOther property can only contain items of type \StructType\DepositOther, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set depositOther value
     * @throws \InvalidArgumentException
     * @param \StructType\DepositOther[] $depositOther
     * @return \StructType\DepositOtherList
     */
    public function setDepositOther(array $depositOther = array())
    {
        // validation for constraint: array
        if ('' !== ($depositOtherArrayErrorMessage = self::validateDepositOtherForArrayConstraintsFromSetDepositOther($depositOther))) {
            throw new \InvalidArgumentException($depositOtherArrayErrorMessage, __LINE__);
        }
        $this->depositOther = $depositOther;
        return $this;
    }
    /**
     * Add item to depositOther value
     * @throws \InvalidArgumentException
     * @param \StructType\DepositOther $item
     * @return \StructType\DepositOtherList
     */
    public function addToDepositOther(\StructType\DepositOther $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof \StructType\DepositOther) {
            throw new \InvalidArgumentException(sprintf('The depositOther property can only contain items of type \StructType\DepositOther, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->depositOther[] = $item;
        return $this;
    }
    /**
     * Get replaceAll value
     * @return bool|null
     */
    public function getReplaceAll()
    {
        return $this->replaceAll;
    }
    /**
     * Set replaceAll value
     * @param bool $replaceAll
     * @return \StructType\DepositOtherList
     */
    public function setReplaceAll($replaceAll = true)
    {
        // validation for constraint: boolean
        if (!is_null($replaceAll) && !is_bool($replaceAll)) {
            throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a bool, %s given', var_export($replaceAll, true), gettype($replaceAll)), __LINE__);
        }
        $this->replaceAll = $replaceAll;
        return $this;
    }
}
