deseretdigital / knobby
Manage knobs and levers for feature control
Installs: 274 319
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 19
Forks: 4
Open Issues: 1
Type:project
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-11-01 21:36:05 UTC
README
knobby
Provides SDK for using feature flags.
Flag Types
Levers
A flag that passes its test if it's turned on.
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 */ }
Knobs
A flag that passes its test if a test value is below the knob's value.
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 */ }
Knobs can also be used to randomly generate a test value within a specified range and then test this random value against the knob's 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. */ }