diff --git a/examples/10-timeout.php b/examples/10-timeout.php new file mode 100644 index 00000000..af589f92 --- /dev/null +++ b/examples/10-timeout.php @@ -0,0 +1,37 @@ + 2, + ]); +} else if (class_exists(Psr18Client::class)) { + $httpClient = HttpClient::create([ + 'timeout' => 2, + ]); + $httpClient = new Psr18Client($httpClient); +} else { + throw new LogicException('No supported http client (for this example) found'); +} + +$unleash = UnleashBuilder::create() + ->withAppName($appName) + ->withAppUrl($appUrl) + ->withInstanceId($instanceId) + ->withHttpClient($httpClient) + ->withHeader('Authorization', $apiKey) + ->build() +; + +if ($unleash->isEnabled('myFeature')) { + echo "myFeature is enabled"; +} else { + echo "myFeature is disabled"; +}