open-feature/validators-hook

OpenFeature 的验证器钩子包


README

a Latest Stable Version Total Downloads PHP 8.0+ License

概述

验证器钩子构造提供了对解析后的功能标志值执行验证的手段。

此包还基于各种 PSR (PHP 标准建议) 如日志接口 (PSR-3) 和基本及扩展编码标准 (PSR-1 和 PSR-12)。

安装

composer require open-feature/validators-hook

使用方法

以下验证器钩子构造可用,但更多正在逐步开发中:

  • RegexpValidatorHook
use OpenFeature\Hooks\Validators\RegexpValidatorHook;

$alphanumericValidator = new RegexpValidatorHook('/^[A-Za-z0-9]+$/');
$hexadecimalValidator = new RegexpValidatorHook('/^[0-9a-f]+$/');
$asciiValidator = new RegexpValidatorHook('/^[ -~]$/');

// this specific invocation will use this validator
$client->resolveStringValue('test-flag', 'deadbeef', null, new EvaluationOptions([$hexadecimalValidator]));

更多示例,请参阅 示例

开发

PHP 版本

此库针对 PHP 8.0 及更高版本。只要您系统中有任何兼容的 PHP 版本,您应该能够使用 OpenFeature SDK。

此包还有一个 .tool-versions 文件,用于与 asdf 等版本管理器一起使用。

安装和依赖

使用 composer install 安装依赖。 composer install 将更新 composer.lock 以包含最新兼容版本。

我们重视尽可能减少运行时依赖项。添加任何依赖项都需要仔细考虑和审查。

测试

使用 composer run test 运行测试。