管理功能控制的旋钮和杠杆

安装数量: 274,282

依赖项: 0

建议者: 0

安全性: 0

星标: 6

关注者: 19

分支: 4

开放问题: 1

类型:项目

1.0.0 2015-03-13 16:50 UTC

This package is not auto-updated.

Last update: 2024-09-20 21:12:03 UTC


README

Build Status

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