original_string: public function addRoleToUser($user, $role)
  	{
  		if (is_string($user)) {
  			$user = $this->getUser($user);
  		} elseif (!property_exists($user, "_id") || !property_exists($user, "roles")) {
  			throw new InvalidArgumentException("user parameter should be the login or a user document");
  		}
  		if (!in_array($role, $user->roles)) {
  			$user->roles[] = $role;
  			$client = clone($this->client);
  			$client->useDatabase($this->usersdb);
  			$client->storeDoc($user);
  		}
  		return true;
  	}
code: public function addRoleToUser($user, $role)
  	{
  		if (is_string($user)) {
  			$user = $this->getUser($user);
  		} elseif (!property_exists($user, "_id") || !property_exists($user, "roles")) {
  			throw new InvalidArgumentException("user parameter should be the login or a user document");
  		}
  		if (!in_array($role, $user->roles)) {
  			$user->roles[] = $role;
  			$client = clone($this->client);
  			$client->useDatabase($this->usersdb);
  			$client->storeDoc($user);
  		}
  		return true;
  	}
code_tokens: public function addRoleToUser ( $ user , $ role ) { if ( is_string ( $ user ) ) { $ user = $ this -> getUser ( $ user ) ; } elseif ( ! property_exists ( $ user , "_id" ) || ! property_exists ( $ user , "roles" ) ) { throw new InvalidArgumentException ( "user parameter should be the login or a user document" ) ; } if ( ! in_array ( $ role , $ user -> roles ) ) { $ user -> roles [ ] = $ role ; $ client = clone ( $ this -> client ) ; $ client -> useDatabase ( $ this -> usersdb ) ; $ client -> storeDoc ( $ user ) ; } return true ; }
docstring: Add a role to a user document
  
  @param string|stdClass $user the user login (as a string) or the user document ( fetched by getUser() method )
  @param string $role the role to add in the list of roles the user belongs to
  @return boolean true if the user $user now belongs to the role $role
  @throws InvalidArgumentException
docstring_tokens: Add a role to a user document