Skip to content

Commit 0cc8668

Browse files
committed
Coerce user keys to strings
1 parent 53d6e35 commit 0cc8668

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/LaunchDarkly/LDUser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LDUser {
3333
* @param array|null $custom Other custom attributes that can be used to create custom rules
3434
*/
3535
public function __construct($key, $secondary = null, $ip = null, $country = null, $email = null, $name = null, $avatar = null, $firstName = null, $lastName= null, $anonymous = null, $custom = []) {
36-
$this->_key = $key;
36+
$this->_key = strval($key);
3737
$this->_secondary = $secondary;
3838
$this->_ip = $ip;
3939
$this->_country = $country;

tests/LDUserTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ public function testLDUserKey() {
1212
$this->assertEquals("[email protected]", $user->toJSON()['key']);
1313
}
1414

15+
public function testCoerceLDUserKey() {
16+
$user = (new LDUserBuilder(3))->build();
17+
$this->assertEquals("string", gettype($user->getKey()));
18+
$this->assertEquals("string", gettype($user->toJSON()['key']));
19+
}
20+
1521
public function testLDUserSecondary() {
1622
$user = (new LDUserBuilder("[email protected]"))->secondary("secondary")->build();
1723
$this->assertEquals("secondary", $user->getSecondary());

0 commit comments

Comments
 (0)