pheature/inmemory-toggle

Pheature 标志内存切换实现库。

0.8.0 2023-12-03 12:49 UTC

This package is auto-updated.

Last update: 2024-09-03 14:29:36 UTC


README

Latest Version on Packagist Quality Score Type coverage Test Coverage Mutation testing badge Maintainability Total Downloads

安装

使用composer包管理器进行安装。

composer require pheature/inmemory-toggle

用法

查看更多示例,请访问https://github.com/pheature-flags/pheature-flags/tree/1.0.x/examples

<?php

declare(strict_types=1);

use Pheature\Core\Toggle\Read\Toggle;
use Pheature\InMemory\Toggle\InMemoryConfig;
use Pheature\InMemory\Toggle\InMemoryFeatureFactory;
use Pheature\InMemory\Toggle\InMemoryFeatureFinder;

require '../vendor/autoload.php';

$config = [
    'toggles' => [
        'feature_1' => [
            'id' => 'feature_1',
            'enabled' => false,
            'strategies' => []
        ],
    ]
];

$toggle = new Toggle(new InMemoryFeatureFinder(
    new InMemoryConfig($config['toggles']),
    new InMemoryFeatureFactory()
));

if ($toggle->isEnabled('feature_1')) {
    echo 'The feature_1 is work in progress.' . PHP_EOL;
}

if (false === $toggle->isEnabled('feature_1')) {
    echo 'The old functionality to be changed when the feature_1 is ready.' . PHP_EOL;
}

贡献

欢迎您的贡献!请首先查看贡献指南

许可证

我们非常相信开源软件,我们围绕它构建了我们的职业生涯,我们觉得我们需要将我们的知识回馈给社区。因此,我们将在BSD-3-Clause许可证下发布所有我们的包。