<?php

namespace StructType;

use \WsdlToPhp\PackageBase\AbstractStructBase;

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