From 78be67cd93719742e0e0169a6b2ff9bffe95086b Mon Sep 17 00:00:00 2001 From: Tom Carrio Date: Sun, 30 Oct 2022 02:17:33 -0400 Subject: [PATCH] feat: provide a base AbstractProvider for provider implementations to use --- .../provider/AbstractProvider.php | 57 +++++++++++++++++++ src/implementation/provider/NoOpProvider.php | 31 +--------- 2 files changed, 59 insertions(+), 29 deletions(-) create mode 100644 src/implementation/provider/AbstractProvider.php diff --git a/src/implementation/provider/AbstractProvider.php b/src/implementation/provider/AbstractProvider.php new file mode 100644 index 0000000..8304e0c --- /dev/null +++ b/src/implementation/provider/AbstractProvider.php @@ -0,0 +1,57 @@ +hooks; + } + + /** + * @param Hook[] $hooks + */ + public function setHooks(array $hooks): void + { + $this->hooks = $hooks; + } +} diff --git a/src/implementation/provider/NoOpProvider.php b/src/implementation/provider/NoOpProvider.php index c9186e6..890bf45 100644 --- a/src/implementation/provider/NoOpProvider.php +++ b/src/implementation/provider/NoOpProvider.php @@ -4,24 +4,13 @@ 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; -class NoOpProvider implements Provider +class NoOpProvider extends AbstractProvider implements Provider { - use LoggerAwareTrait; - - private static string $NAME = 'NoOpProvider'; - - public function getMetadata(): MetadataInterface - { - return new Metadata(self::$NAME); - } + protected static string $NAME = 'NoOpProvider'; public function resolveBooleanValue(string $flagKey, bool $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface { @@ -50,20 +39,4 @@ public function resolveObjectValue(string $flagKey, $defaultValue, ?EvaluationCo { return ResolutionDetailsFactory::fromSuccess($defaultValue); } - - /** - * @return Hook[] - */ - public function getHooks(): array - { - return []; - } - - /** - * @param Hook[] $hooks - */ - public function setHooks(array $hooks): void - { - // no-op - } }