Skip to content

Commit 91479bc

Browse files
committed
Merge pull request #9 from launchdarkly/jko/fix-user-target
Fix two bugs in user targets
2 parents ee75e5d + aa05b55 commit 91479bc

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/LaunchDarkly/LDClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ protected static function _decode($json, $user) {
212212
$ts = empty($v['targets']) ? [] : $v['targets'];
213213
$targets = array_map($makeTarget, $ts);
214214
if (isset($v['userTarget'])) {
215-
return new Variation($v['value'], $v['weight'], $targets, $v['userTarget']);
215+
return new Variation($v['value'], $v['weight'], $targets, $makeTarget($v['userTarget']));
216216
}
217217
else {
218218
return new Variation($v['value'], $v['weight'], $targets, null);

src/LaunchDarkly/TargetRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public function __construct($attribute, $operator, $values) {
1515
$this->_values = $values;
1616
}
1717

18+
public function isKey() {
19+
return $this->_attribute == "key";
20+
}
21+
1822

1923
public function matchTarget($user) {
2024
$u_value = null;

src/LaunchDarkly/Variation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function matchUser($user) {
2727

2828
public function matchTarget($user) {
2929
foreach($this->_targets as $target) {
30-
if ($this->_userTarget != null && $target->_attribute == "key") {
30+
if ($this->_userTarget != null && $target->isKey()) {
3131
continue;
3232
}
3333
if ($target->matchTarget($user)) {

0 commit comments

Comments
 (0)