Skip to content

Commit

Permalink
Merge pull request #23 from flix-tech/feature/interface-extraction
Browse files Browse the repository at this point in the history
Extract `ClientInterface` from `ConfigCatClient`
  • Loading branch information
z4kn4fein authored Aug 5, 2022
2 parents 53e7a48 + 5698a6d commit c12ede1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
66 changes: 66 additions & 0 deletions src/ClientInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace ConfigCat;

/**
* A client for handling configurations provided by ConfigCat.
* @package ConfigCat
*/
interface ClientInterface
{
/**
* Gets a value of a feature flag or setting identified by the given key.
*
* @param string $key The identifier of the configuration value.
* @param mixed $defaultValue In case of any failure, this value will be returned.
* @param User|null $user The user object to identify the caller.
* @return mixed The configuration value identified by the given key.
*/
public function getValue(string $key, $defaultValue, User $user = null);

/**
* Gets the Variation ID (analytics) of a feature flag or setting by the given key.
*
* @param string $key The identifier of the configuration value.
* @param mixed $defaultVariationId In case of any failure, this value will be returned.
* @param User|null $user The user object to identify the caller.
* @return mixed The Variation ID identified by the given key.
*/
public function getVariationId(string $key, $defaultVariationId, User $user = null);

/**
* Gets the Variation IDs (analytics) of all feature flags or settings.
*
* @param User|null $user The user object to identify the caller.
* @return array of all Variation IDs.
*/
public function getAllVariationIds(User $user = null): array;

/**
* Gets the key of a setting and its value identified by the given Variation ID (analytics).
*
* @param string $variationId The Variation ID.
* @return Pair|null of the key and value of a setting.
*/
public function getKeyAndValue(string $variationId): ?Pair;

/**
* Gets a collection of all setting keys.
*
* @return array of keys.
*/
public function getAllKeys(): array;

/**
* Gets the values of all feature flags or settings.
*
* @param User|null $user The user object to identify the caller.
* @return array of values.
*/
public function getAllValues(User $user = null): array;

/**
* Initiates a force refresh on the cached configuration.
*/
public function forceRefresh(): void;
}
2 changes: 1 addition & 1 deletion src/ConfigCatClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* A client for handling configurations provided by ConfigCat.
* @package ConfigCat
*/
final class ConfigCatClient
final class ConfigCatClient implements ClientInterface
{
/** @var string */
const SDK_VERSION = "6.0.0";
Expand Down

0 comments on commit c12ede1

Please sign in to comment.