The UserInfo
The League\Uri\Components\UserInfo
class eases user information creation and manipulation.
This URI component object exposes the package common API,
but also provide specific methods to work with the URI user information part.
Creating a new object
public UserInfo::__construct($user, $pass = null): void
Accessing User information content
public UserInfo::getUser(): ?string
public UserInfo::getPass(): ?string
To access the user login and password information you need to call the respective UserInfo::getUser
and UserInfo::getPass
methods like shown below.
$info = new UserInfo('foo', 'bar');
$info->getUser(); //return 'foo'
$info->getPass(); //return 'bar'
Modifying the user information
public UserInfo::withUserInfo($user, $password = null): self
Because the UserInfo
is composed of at most two components the UserInfo::withUserInfo
method is introduced to ease modify the object content.
$info = new UserInfo('foo', 'bar');
$new_info = $info->withUserInfo('john', 'doe');
echo $new_info; //displays john:doe
echo $info; //displays foo:bar