<?php
use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for units StructType
 * Meta informations extracted from the WSDL
 * - documentation: The units element is optional when a newVG224 is being added and can be added using updateVG224Gateway. | The units element is optional when a newVG224 is being added and can be added using updateVG224Gateway. | The units element is
 * optional when a newVG224 is being added and can be added using updateVG224Gateway.
 * @subpackage Structs
 */
class Units extends AbstractStructBase
{
    /**
     * The unit
     * Meta informations extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var Unit[]
     */
    public $unit;
    /**
     * Constructor method for units
     * @uses Units::setUnit()
     * @param Unit[] $unit
     */
    public function __construct(array $unit = array())
    {
        $this
            ->setUnit($unit);
    }
    /**
     * Get unit value
     * @return Unit[]|null
     */
    public function getUnit()
    {
        return $this->unit;
    }
    /**
     * Set unit value
     * @throws \InvalidArgumentException
     * @param Unit[] $unit
     * @return Units
     */
    public function setUnit(array $unit = array())
    {
        foreach ($unit as $unitsUnitItem) {
            // validation for constraint: itemType
            if (!$unitsUnitItem instanceof Unit) {
                throw new \InvalidArgumentException(sprintf('The unit property can only contain items of Unit, "%s" given', is_object($unitsUnitItem) ? get_class($unitsUnitItem) : gettype($unitsUnitItem)), __LINE__);
            }
        }
        $this->unit = $unit;
        return $this;
    }
    /**
     * Add item to unit value
     * @throws \InvalidArgumentException
     * @param Unit $item
     * @return Units
     */
    public function addToUnit(Unit $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof Unit) {
            throw new \InvalidArgumentException(sprintf('The unit property can only contain items of Unit, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
        }
        $this->unit[] = $item;
        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 Units
     */
    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__;
    }
}
