-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide a base AbstractProvider for provider implementations to…
… use
- Loading branch information
Showing
2 changed files
with
59 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenFeature\implementation\provider; | ||
|
||
use OpenFeature\implementation\common\Metadata; | ||
use OpenFeature\interfaces\common\Metadata as MetadataInterface; | ||
use OpenFeature\interfaces\flags\EvaluationContext; | ||
use OpenFeature\interfaces\hooks\Hook; | ||
use OpenFeature\interfaces\provider\Provider; | ||
use OpenFeature\interfaces\provider\ResolutionDetails as ResolutionDetailsInterface; | ||
use Psr\Log\LoggerAwareTrait; | ||
|
||
abstract class AbstractProvider implements Provider | ||
{ | ||
use LoggerAwareTrait; | ||
|
||
protected static string $NAME = 'AbstractProvider'; | ||
|
||
/** @var Hook[] $hooks */ | ||
private array $hooks = []; | ||
|
||
public function getMetadata(): MetadataInterface | ||
{ | ||
return new Metadata(self::$NAME); | ||
} | ||
|
||
abstract public function resolveBooleanValue(string $flagKey, bool $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface; | ||
|
||
abstract public function resolveStringValue(string $flagKey, string $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface; | ||
|
||
abstract public function resolveIntegerValue(string $flagKey, int $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface; | ||
|
||
abstract public function resolveFloatValue(string $flagKey, float $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
abstract public function resolveObjectValue(string $flagKey, $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface; | ||
|
||
/** | ||
* @return Hook[] | ||
*/ | ||
public function getHooks(): array | ||
{ | ||
return $this->hooks; | ||
} | ||
|
||
/** | ||
* @param Hook[] $hooks | ||
*/ | ||
public function setHooks(array $hooks): void | ||
{ | ||
$this->hooks = $hooks; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters