src/User/User.php
public function updateMetaData(string $key, string $value): User
    {
        $previous = get_user_meta($this->ID, $key, true);

        if ($previous === $value) {
            return $this;
        }

        $update = update_user_meta($this->ID, $key, $value, $previous);

        if (false === $update) {
            throw new UserException("Cannot update user meta data with a key of [$key]");
        }

        return $this;
    }
public function updateMetaData(string $key, string $value): User
    {
        $previous = get_user_meta($this->ID, $key, true);

        if ($previous === $value) {
            return $this;
        }

        $update = update_user_meta($this->ID, $key, $value, $previous);

        if (false === $update) {
            throw new UserException("Cannot update user meta data with a key of [$key]");
        }

        return $this;
    }
public function updateMetaData ( string $ key , string $ value ) : User { $ previous = get_user_meta ( $ this -> ID , $ key , true ) ; if ( $ previous === $ value ) { return $ this ; } $ update = update_user_meta ( $ this -> ID , $ key , $ value , $ previous ) ; if ( false === $ update ) { throw new UserException ( "Cannot update user meta data with a key of [$key]" ) ; } return $ this ; }
Update single user meta data.

@param string $key
@param string $value

@throws UserException

@return User
Update single user meta data .