<?php
use \WsdlToPhp\PackageBase\AbstractStructBase;

/**
 * This class stands for addUserRoles StructType
 * @subpackage Structs
 */
class AddUserRoles extends XCommonMembersExtension
{
    /**
     * The userRole
     * Meta informations extracted from the WSDL
     * - maxOccurs: unbounded
     * - minOccurs: 0
     * @var XUserGroupRoles[]
     */
    public $userRole;
    /**
     * Constructor method for addUserRoles
     * @uses AddUserRoles::setUserRole()
     * @param XUserGroupRoles[] $userRole
     */
    public function __construct(array $userRole = array())
    {
        $this
            ->setUserRole($userRole);
    }
    /**
     * Get userRole value
     * @return XUserGroupRoles[]|null
     */
    public function getUserRole()
    {
        return $this->userRole;
    }
    /**
     * Set userRole value
     * @throws \InvalidArgumentException
     * @param XUserGroupRoles[] $userRole
     * @return AddUserRoles
     */
    public function setUserRole(array $userRole = array())
    {
        foreach ($userRole as $addUserRolesUserRoleItem) {
            // validation for constraint: itemType
            if (!$addUserRolesUserRoleItem instanceof XUserGroupRoles) {
                throw new \InvalidArgumentException(sprintf('The userRole property can only contain items of XUserGroupRoles, "%s" given', is_object($addUserRolesUserRoleItem) ? get_class($addUserRolesUserRoleItem) : gettype($addUserRolesUserRoleItem)), __LINE__);
            }
        }
        $this->userRole = $userRole;
        return $this;
    }
    /**
     * Add item to userRole value
     * @throws \InvalidArgumentException
     * @param XUserGroupRoles $item
     * @return AddUserRoles
     */
    public function addToUserRole(XUserGroupRoles $item)
    {
        // validation for constraint: itemType
        if (!$item instanceof XUserGroupRoles) {
            throw new \InvalidArgumentException(sprintf('The userRole property can only contain items of XUserGroupRoles, "%s" given', is_object($item) ? get_class($item) : gettype($item)), __LINE__);
        }
        $this->userRole[] = $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 AddUserRoles
     */
    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__;
    }
}
