Slack\ApiClient::getUserByName PHP Method

getUserByName() public method

If the user could not be found, the returned promise is rejected with a UserNotFoundException exception.
public getUserByName ( $username ) : React\Promise\PromiseInterface
return React\Promise\PromiseInterface A promise for a user object.
    public function getUserByName($username)
    {
        return $this->getUsers()->then(function (array $users) use($username) {
            foreach ($users as $user) {
                if ($user->getUsername() === $username) {
                    return $user;
                }
            }
            throw new UserNotFoundException("The user \"{$username}\" does not exist.");
        });
    }