<commit_before><?php

use Predis\Client;
use Qandidate\Toggle\ToggleCollection\PredisCollection;
use Qandidate\Toggle\ToggleManager;
use Silex\Application;

$app = new Application();

$app->register(new Predis\Silex\PredisServiceProvider(), array(
    'predis.parameters' => 'tcp://127.0.0.1:6379'
));

$app['toggle_manager.prefix']     = 'toggle_namespace';
$app['toggle_manager.collection'] = $app->share(function ($app) {
    return new PredisCollection($app['toggle_manager.prefix'], $app['predis']);
});

$app['toggle_manager']        = $app->share(function ($app) {
    return new ToggleManager($app['toggle_manager.collection']);
});

return $app;<commit_msg>Expose toggles in api<commit_after><?php

use Predis\Client;
use Qandidate\Toggle\ToggleCollection\PredisCollection;
use Qandidate\Toggle\ToggleManager;
use Silex\Application;

$app = new Application();

$app->register(new Predis\Silex\PredisServiceProvider(), array(
    'predis.parameters' => 'tcp://127.0.0.1:6379'
));

$app['toggle_manager.prefix']     = 'toggle_namespace';
$app['toggle_manager.collection'] = $app->share(function ($app) {
    return new PredisCollection($app['toggle_manager.prefix'], $app['predis']);
});

$app['toggle_manager']        = $app->share(function ($app) {
    return new ToggleManager($app['toggle_manager.collection']);
});

$app->get('/toggles', function() use ($app) {
    $toggles = $app['toggle_manager']->all();

    $names = array_keys($toggles);

    return $app->json(array('toggles' => $names));
});

return $app;
{'fraction_non_alphanumeric': 0.18754098360655738, 'fraction_numerical': 0.013114754098360656, 'mean_word_length': 5.722466960352423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6297049', 'n_tokens_mistral': 508, 'n_tokens_neox': 499, 'n_words': 81}