Skip to content

Commit ea02d03

Browse files
committed
Error handling for userTarget
1 parent bfa8ce5 commit ea02d03

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/LaunchDarkly/LDClient.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,12 @@ protected static function _decode($json, $user) {
207207

208208
$ts = empty($v['targets']) ? [] : $v['targets'];
209209
$targets = array_map($makeTarget, $ts);
210-
return new Variation($v['value'], $v['weight'], $targets, $v['userTarget']);
210+
if (isset($v['userTarget'])) {
211+
return new Variation($v['value'], $v['weight'], $targets, $v['userTarget']);
212+
}
213+
else {
214+
return new Variation($v['value'], $v['weight'], $targets, null);
215+
}
211216
};
212217

213218
$vs = empty($json['variations']) ? [] : $json['variations'];

0 commit comments

Comments
 (0)