<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for MaximumItemRequirementsDetailsType StructType
 * Meta informations extracted from the WSDL
 * - documentation: A means of limiting unpaying or low feedback bidders.
 * @subpackage Structs
 */
class MaximumItemRequirementsDetailsType extends AbstractStructBase
{
    /**
     * The MaximumItemCount
     * Meta informations extracted from the WSDL
     * - documentation: The maximum number of items allowed for this buyer.
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var int[]
     */
    public $MaximumItemCount;
    /**
     * The MinimumFeedbackScore
     * Meta informations extracted from the WSDL
     * - documentation: The Minimum Feedback Score required for a buyer who wants to purchase this item.
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var int[]
     */
    public $MinimumFeedbackScore;
    /**
     * The any
     * @var \DOMDocument
     */
    public $any;
    /**
     * Constructor method for MaximumItemRequirementsDetailsType
     * @uses MaximumItemRequirementsDetailsType::setMaximumItemCount()
     * @uses MaximumItemRequirementsDetailsType::setMinimumFeedbackScore()
     * @uses MaximumItemRequirementsDetailsType::setAny()
     * @param int[] $maximumItemCount
     * @param int[] $minimumFeedbackScore
     * @param \DOMDocument $any
     */
    public function __construct(array $maximumItemCount = array(), array $minimumFeedbackScore = array(), \DOMDocument $any = null)
    {
        $this
            ->setMaximumItemCount($maximumItemCount)
            ->setMinimumFeedbackScore($minimumFeedbackScore)
            ->setAny($any);
    }
    /**
     * Get MaximumItemCount value
     * @return int[]|null
     */
    public function getMaximumItemCount()
    {
        return $this->MaximumItemCount;
    }
    /**
     * This method is responsible for validating the values passed to the setMaximumItemCount method
     * This method is willingly generated in order to preserve the one-line inline validation within the setMaximumItemCount method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateMaximumItemCountForArrayConstraintsFromSetMaximumItemCount(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $maximumItemRequirementsDetailsTypeMaximumItemCountItem) {
            // validation for constraint: itemType
            if (!(is_int($maximumItemRequirementsDetailsTypeMaximumItemCountItem) || ctype_digit($maximumItemRequirementsDetailsTypeMaximumItemCountItem))) {
                $invalidValues[] = is_object($maximumItemRequirementsDetailsTypeMaximumItemCountItem) ? get_class($maximumItemRequirementsDetailsTypeMaximumItemCountItem) : sprintf('%s(%s)', gettype($maximumItemRequirementsDetailsTypeMaximumItemCountItem), var_export($maximumItemRequirementsDetailsTypeMaximumItemCountItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The MaximumItemCount property can only contain items of type int, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set MaximumItemCount value
     * @throws \InvalidArgumentException
     * @param int[] $maximumItemCount
     * @return \StructType\MaximumItemRequirementsDetailsType
     */
    public function setMaximumItemCount(array $maximumItemCount = array())
    {
        // validation for constraint: array
        if ('' !== ($maximumItemCountArrayErrorMessage = self::validateMaximumItemCountForArrayConstraintsFromSetMaximumItemCount($maximumItemCount))) {
            throw new \InvalidArgumentException($maximumItemCountArrayErrorMessage, __LINE__);
        }
        $this->MaximumItemCount = $maximumItemCount;
        return $this;
    }
    /**
     * Add item to MaximumItemCount value
     * @throws \InvalidArgumentException
     * @param int $item
     * @return \StructType\MaximumItemRequirementsDetailsType
     */
    public function addToMaximumItemCount($item)
    {
        // validation for constraint: itemType
        if (!(is_int($item) || ctype_digit($item))) {
            throw new \InvalidArgumentException(sprintf('The MaximumItemCount property can only contain items of type int, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->MaximumItemCount[] = $item;
        return $this;
    }
    /**
     * Get MinimumFeedbackScore value
     * @return int[]|null
     */
    public function getMinimumFeedbackScore()
    {
        return $this->MinimumFeedbackScore;
    }
    /**
     * This method is responsible for validating the values passed to the setMinimumFeedbackScore method
     * This method is willingly generated in order to preserve the one-line inline validation within the setMinimumFeedbackScore method
     * @param array $values
     * @return string A non-empty message if the values does not match the validation rules
     */
    public static function validateMinimumFeedbackScoreForArrayConstraintsFromSetMinimumFeedbackScore(array $values = array())
    {
        $message = '';
        $invalidValues = [];
        foreach ($values as $maximumItemRequirementsDetailsTypeMinimumFeedbackScoreItem) {
            // validation for constraint: itemType
            if (!(is_int($maximumItemRequirementsDetailsTypeMinimumFeedbackScoreItem) || ctype_digit($maximumItemRequirementsDetailsTypeMinimumFeedbackScoreItem))) {
                $invalidValues[] = is_object($maximumItemRequirementsDetailsTypeMinimumFeedbackScoreItem) ? get_class($maximumItemRequirementsDetailsTypeMinimumFeedbackScoreItem) : sprintf('%s(%s)', gettype($maximumItemRequirementsDetailsTypeMinimumFeedbackScoreItem), var_export($maximumItemRequirementsDetailsTypeMinimumFeedbackScoreItem, true));
            }
        }
        if (!empty($invalidValues)) {
            $message = sprintf('The MinimumFeedbackScore property can only contain items of type int, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues)));
        }
        unset($invalidValues);
        return $message;
    }
    /**
     * Set MinimumFeedbackScore value
     * @throws \InvalidArgumentException
     * @param int[] $minimumFeedbackScore
     * @return \StructType\MaximumItemRequirementsDetailsType
     */
    public function setMinimumFeedbackScore(array $minimumFeedbackScore = array())
    {
        // validation for constraint: array
        if ('' !== ($minimumFeedbackScoreArrayErrorMessage = self::validateMinimumFeedbackScoreForArrayConstraintsFromSetMinimumFeedbackScore($minimumFeedbackScore))) {
            throw new \InvalidArgumentException($minimumFeedbackScoreArrayErrorMessage, __LINE__);
        }
        $this->MinimumFeedbackScore = $minimumFeedbackScore;
        return $this;
    }
    /**
     * Add item to MinimumFeedbackScore value
     * @throws \InvalidArgumentException
     * @param int $item
     * @return \StructType\MaximumItemRequirementsDetailsType
     */
    public function addToMinimumFeedbackScore($item)
    {
        // validation for constraint: itemType
        if (!(is_int($item) || ctype_digit($item))) {
            throw new \InvalidArgumentException(sprintf('The MinimumFeedbackScore property can only contain items of type int, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__);
        }
        $this->MinimumFeedbackScore[] = $item;
        return $this;
    }
    /**
     * Get any value
     * @uses \DOMDocument::loadXML()
     * @param bool $asString true: returns XML string, false: returns \DOMDocument
     * @return \DOMDocument|null
     */
    public function getAny($asString = true)
    {
        $domDocument = null;
        if (!empty($this->any) && !$asString) {
            $domDocument = new \DOMDocument('1.0', 'UTF-8');
            $domDocument->loadXML($this->any);
        }
        return $asString ? $this->any : $domDocument;
    }
    /**
     * Set any value
     * @uses \DOMDocument::hasChildNodes()
     * @uses \DOMDocument::saveXML()
     * @uses \DOMNode::item()
     * @param \DOMDocument $any
     * @return \StructType\MaximumItemRequirementsDetailsType
     */
    public function setAny(\DOMDocument $any = null)
    {
        $this->any = ($any instanceof \DOMDocument) && $any->hasChildNodes() ? $any->saveXML($any->childNodes->item(0)) : $any;
        return $this;
    }
    /**
     * Method called when an object has been exported with var_export() functions
     * It allows to return an object instantiated with the values
     * @see AbstractStructBase::__set_state()
     * @uses AbstractStructBase::__set_state()
     * @param array $array the exported values
     * @return \StructType\MaximumItemRequirementsDetailsType
     */
    public static function __set_state(array $array)
    {
        return parent::__set_state($array);
    }
    /**
     * Method returning the class name
     * @return string __CLASS__
     */
    public function __toString()
    {
        return __CLASS__;
    }
}
