LDUser
in package
Contains specific attributes of a user browsing your site.
LDUser supports only a subset of the behaviors that are available with the newer LDContext
type. An LDUser is equivalent to an individual LDContext that has a kind
of LDContext::DEFAULT_KIND;
it also has more constraints on attribute values than LDContext does (for instance, built-in attributes such as
LDUserBuilder::email() can only have string values). Older LaunchDarkly SDKs only had the
LDUser model, and the LDUser type has been retained for backward compatibility, but it may be removed in a
future SDK version. Therefore, developers are recommended to migrate toward using LDContext.
The only mandatory property property is the key, which must uniquely identify each user. For authenticated users, this may be a username or e-mail address. For anonymous users, it could be an IP address or session ID.
Use LDUserBuilder to construct instances of this class.
Table of Contents
- __construct() : LDUser
- Constructor for directly creating an instance.
- getAnonymous() : bool|null
- getAvatar() : string|null
- getCountry() : string|null
- getCustom() : array<string|int, mixed>|null
- getEmail() : string|null
- getFirstName() : string|null
- getIP() : string|null
- getKey() : string
- getLastName() : string|null
- getName() : string|null
- getPrivateAttributeNames() : array<string|int, mixed>|null
- isKeyBlank() : bool
Methods
__construct()
Constructor for directly creating an instance.
public
__construct(string $key[, string|null $secondary = null ][, string|null $ip = null ][, string|null $country = null ][, string|null $email = null ][, string|null $name = null ][, string|null $avatar = null ][, string|null $firstName = null ][, string|null $lastName = null ][, bool|null $anonymous = null ][, array<string|int, mixed>|null $custom = [] ][, array<string|int, mixed>|null $privateAttributeNames = [] ]) : LDUser
It is preferable to use LDUserBuilder instead of this constructor.
Parameters
- $key : string
-
Unique key for the user. For authenticated users, this may be a username or e-mail address. For anonymous users, this could be an IP address or session ID.
- $secondary : string|null = null
-
Obsolete parameter that is ignored if present, retained to avoid breaking code that called this constructor
- $ip : string|null = null
-
The user's IP address (optional)
- $country : string|null = null
-
The user's country, as an ISO 3166-1 alpha-2 code (e.g. 'US') (optional)
- $email : string|null = null
-
The user's e-mail address (optional)
- $name : string|null = null
-
The user's full name (optional)
- $avatar : string|null = null
-
A URL pointing to the user's avatar image (optional)
- $firstName : string|null = null
-
The user's first name (optional)
- $lastName : string|null = null
-
The user's last name (optional)
- $anonymous : bool|null = null
-
Whether this is an anonymous user
- $custom : array<string|int, mixed>|null = []
-
Other custom attributes that can be used to create custom rules
- $privateAttributeNames : array<string|int, mixed>|null = []
Return values
LDUser —getAnonymous()
public
getAnonymous() : bool|null
Return values
bool|null —getAvatar()
public
getAvatar() : string|null
Return values
string|null —getCountry()
public
getCountry() : string|null
Return values
string|null —getCustom()
public
getCustom() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —getEmail()
public
getEmail() : string|null
Return values
string|null —getFirstName()
public
getFirstName() : string|null
Return values
string|null —getIP()
public
getIP() : string|null
Return values
string|null —getKey()
public
getKey() : string
Return values
string —getLastName()
public
getLastName() : string|null
Return values
string|null —getName()
public
getName() : string|null
Return values
string|null —getPrivateAttributeNames()
public
getPrivateAttributeNames() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —isKeyBlank()
public
isKeyBlank() : bool