|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace OpenFeature\implementation\provider; |
| 6 | + |
| 7 | +use OpenFeature\implementation\common\Metadata; |
| 8 | +use OpenFeature\interfaces\common\Metadata as MetadataInterface; |
| 9 | +use OpenFeature\interfaces\flags\EvaluationContext; |
| 10 | +use OpenFeature\interfaces\hooks\Hook; |
| 11 | +use OpenFeature\interfaces\provider\Provider; |
| 12 | +use OpenFeature\interfaces\provider\ResolutionDetails as ResolutionDetailsInterface; |
| 13 | +use Psr\Log\LoggerAwareTrait; |
| 14 | + |
| 15 | +abstract class AbstractProvider implements Provider |
| 16 | +{ |
| 17 | + use LoggerAwareTrait; |
| 18 | + |
| 19 | + protected static string $NAME = 'AbstractProvider'; |
| 20 | + |
| 21 | + /** @var Hook[] $hooks */ |
| 22 | + private array $hooks = []; |
| 23 | + |
| 24 | + public function getMetadata(): MetadataInterface |
| 25 | + { |
| 26 | + return new Metadata(self::$NAME); |
| 27 | + } |
| 28 | + |
| 29 | + abstract public function resolveBooleanValue(string $flagKey, bool $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface; |
| 30 | + |
| 31 | + abstract public function resolveStringValue(string $flagKey, string $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface; |
| 32 | + |
| 33 | + abstract public function resolveIntegerValue(string $flagKey, int $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface; |
| 34 | + |
| 35 | + abstract public function resolveFloatValue(string $flagKey, float $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface; |
| 36 | + |
| 37 | + /** |
| 38 | + * @inheritdoc |
| 39 | + */ |
| 40 | + abstract public function resolveObjectValue(string $flagKey, $defaultValue, ?EvaluationContext $context = null): ResolutionDetailsInterface; |
| 41 | + |
| 42 | + /** |
| 43 | + * @return Hook[] |
| 44 | + */ |
| 45 | + public function getHooks(): array |
| 46 | + { |
| 47 | + return $this->hooks; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * @param Hook[] $hooks |
| 52 | + */ |
| 53 | + public function setHooks(array $hooks): void |
| 54 | + { |
| 55 | + $this->hooks = $hooks; |
| 56 | + } |
| 57 | +} |
0 commit comments