deseretdigital / knobby
管理功能控制的旋钮和杠杆
1.0.0
2015-03-13 16:50 UTC
Requires (Dev)
- codacy/coverage: dev-master
- mockery/mockery: ~0.9.3
- phpunit/php-invoker: ~1.1
- phpunit/phpunit: ~4.0
- raveren/kint: dev-1.0.0-wip
This package is not auto-updated.
Last update: 2024-09-20 21:12:03 UTC
README
knobby
提供SDK,用于使用功能标志。
标志类型
杠杆
如果开启,则通过其测试的标志。
include('./vendor/autoload.php'); $config = array( array( 'name' => 'exampleOn', 'on' => true, 'type' => 'lever', ), array( 'name' => 'exampleOff', 'on' => false, 'type' => 'lever', ), ); $knobby = new \DDM\Knobby\Knobby(); $knobby->loadConfigArray($config); if ($knobby->test('exampleOn')) { /* feature code here will run as the lever is on */ } if ($knobby->test('exampleOff')) { /* feature code here will not run as the lever is off */ }
旋钮
如果测试值低于旋钮的值,则通过其测试的标志。
include('./vendor/autoload.php'); $config = array( array( 'name' => 'testKnob', 'type' => 'knob', 'value' => 15, ), ); $knobby = new \DDM\Knobby\Knobby($config); $userValue = 20; if ($knobby->test('testKnob', $userValue)) { /* feature code here will not run, since the user value is greater than the allowed value */ }
旋钮还可以用于在指定范围内随机生成一个测试值,然后测试这个随机值是否与旋钮的值匹配。
include('./vendor/autoload.php'); $config = array( array( 'name' => 'testKnob', 'type' => 'knob', 'min' => '10', 'max' => '50', 'value' => 15, ), ); $knobby = new \DDM\Knobby\Knobby($config); if ($knobby->test('testKnob')) { /* feature code here may or may not run depending on the value of the randomly generated test value between 10 and 50. */ }