@@ -51,6 +51,10 @@ public function __construct($apiKey, $options = []) {
5151 $ this ->_client = $ this ->_make_client ($ options );
5252 }
5353
54+ public function getFlag ($ key , $ user , $ default = false ) {
55+ return $ this ->toggle ($ key , $ user , $ default );
56+ }
57+
5458 /**
5559 * Calculates the value of a feature flag for a given user.
5660 *
@@ -60,13 +64,13 @@ public function __construct($apiKey, $options = []) {
6064 *
6165 * @return boolean Whether or not the flag should be enabled, or `default` if the flag is disabled in the LaunchDarkly control panel
6266 */
63- public function getFlag ($ key , $ user , $ default = false ) {
67+ public function toggle ($ key , $ user , $ default = false ) {
6468 if ($ this ->_offline ) {
6569 return $ default ;
6670 }
6771
6872 try {
69- $ flag = $ this ->_getFlag ($ key , $ user , $ default );
73+ $ flag = $ this ->_toggle ($ key , $ user , $ default );
7074
7175 if (is_null ($ flag )) {
7276 $ this ->_sendFlagRequestEvent ($ key , $ user , $ default );
@@ -90,7 +94,7 @@ public function getFlag($key, $user, $default = false) {
9094
9195 /**
9296 * Puts the LaunchDarkly client in offline mode.
93- * In offline mode, all calls to `getFlag ` will return the default value, and `track` will be a no-op.
97+ * In offline mode, all calls to `toggle ` will return the default value, and `track` will be a no-op.
9498 *
9599 */
96100 public function setOffline () {
@@ -163,13 +167,13 @@ protected function _sendFlagRequestEvent($key, $user, $value) {
163167 $ this ->_eventProcessor ->enqueue ($ event );
164168 }
165169
166- protected function _getFlag ($ key , $ user , $ default ) {
170+ protected function _toggle ($ key , $ user , $ default ) {
167171 try {
168172 $ response = $ this ->_client ->get ("/api/eval/features/ $ key " );
169173 return self ::_decode ($ response ->json (), $ user );
170174 } catch (BadResponseException $ e ) {
171175 $ code = $ e ->getResponse ()->getStatusCode ();
172- error_log ("LDClient::getFlag received HTTP status code $ code, using default " );
176+ error_log ("LDClient::toggle received HTTP status code $ code, using default " );
173177 return $ default ;
174178 }
175179 }
0 commit comments