Manage knobs and levers for feature control

Installs: 274 362

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 19

Forks: 4

Open Issues: 1

Type:project

1.0.0 2015-03-13 16:50 UTC

This package is not auto-updated.

Last update: 2024-12-13 22:06:41 UTC


README

Build Status

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.
    */
}